Lesson 4 of 5 · 9 min
Services, sharing and open ports
Turn off sharing services you do not use, see what is actually listening for connections, and turn on the Application Firewall.
Every sharing service you leave on is a small network server running on your Mac, waiting for someone to connect to it. Most people turn one on once, for one task, and never turn it off. This lesson covers finding and closing those, then adding a firewall on top as a second layer.
Sharing services
On current macOS, sharing services live in System Settings → General → Sharing: File Sharing, Screen Sharing, Remote Login (SSH), Remote Management, Media Sharing, Content Caching, Internet Sharing, Printer Sharing, and a few others depending on the Mac. Each one is off by default and stays off until you turn it on for a specific reason, such as sending a file to another Mac on the same network or letting a helper connect remotely.
- If you turned on File Sharing once to move files between two Macs, or Screen Sharing to get help from someone, turn it back off from the same Sharing pane once you are done.
- Remote Login opens SSH access to your Mac. Apple’s own documentation for it says plainly that “allowing remote login to your Mac can make it less secure.” Leave it off unless you specifically need to connect to this Mac from elsewhere.
- If several of these show as on and you do not remember turning them on, that alone is worth investigating.
Seeing what is actually listening
Turning sharing services off in System Settings closes the ones Apple exposes a switch for, but other software (a media server, a development tool, a printer driver) can open its own listening ports without asking. lsof (list open files, which on Unix includes network sockets) can show you every process currently waiting for an incoming TCP connection:
lsof -iTCP -sTCP:LISTEN -n -P
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rapportd 1442 admin 15u IPv4 ... 0t0 TCP *:64654 (LISTEN)
ControlCe 1775 admin 9u IPv4 ... 0t0 TCP *:7000 (LISTEN)Each line is one process listening on one port: the command name, its process ID, the address it is bound to (* means every network interface, 127.0.0.1 means local connections only), and the port number after the colon. -n and -P tell lsof to show raw addresses and port numbers instead of resolving them, which is both faster and clearer. A port bound only to 127.0.0.1 is reachable only from the Mac itself; a port bound to * can, network permitting, be reached from other devices. Some entries will be Apple’s own background services (like the AirDrop/Handoff helper rapportd, or Control Center’s AirPlay receiver); the ones worth questioning are apps you installed that you did not expect to be listening at all.
The Application Firewall
The Application Firewall, in System Settings → Network → Firewall, is a second layer on top of closing unused services: rather than blocking by port number, it decides per app whether that app may accept incoming connections at all. Apple describes it as protecting the Mac “from unwanted contact initiated by other computers when you’re connected to the internet or a network,” while still letting you allow specific apps or services through.
| Firewall option | What it does |
|---|---|
| Block all incoming connections | Prevents incoming connections to nonessential services and apps, leaving only basic services needed for the Mac to find other computers on the network. |
| Automatically allow signed software | Lets built-in or downloaded apps signed by a valid certificate receive incoming connections without asking. Turning this off means more prompts, but fewer silent exceptions. |
| Enable stealth mode | Stops the Mac responding to probing requests, including ping (ICMP), that could otherwise be used to detect that it exists on a network. |
You can check the firewall’s current state from Terminal without changing anything:
/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
Firewall is enabled. (State = 1)
/usr/libexec/ApplicationFirewall/socketfilterfw --getstealthmode
Firewall stealth mode is offTurning the firewall on and enabling stealth mode both require an administrator password; the read-only --get commands above do not change anything.
Key takeaways
- Sharing services (File Sharing, Screen Sharing, Remote Login and others) live in System Settings → General → Sharing, are off by default, and should be turned back off once a specific task is done.
- `lsof -iTCP -sTCP:LISTEN -n -P` lists every process currently listening for incoming TCP connections, so you can spot ports you did not expect to be open.
- A port bound to `127.0.0.1` is local-only; one bound to `*` can potentially be reached from the network.
- The Application Firewall controls incoming connections per app; stealth mode stops the Mac responding to probes like ping.
- The Application Firewall does not filter outgoing connections.
Check yourself
1. What does `lsof -iTCP -sTCP:LISTEN -n -P` show you?
- Every file ever opened on the Mac
- Every process currently listening for incoming TCP connections, with its port — Right.
- A list of blocked IP addresses
- The Mac’s Wi-Fi password
This exact combination of flags filters `lsof` down to processes with an open, listening TCP socket, showing raw addresses and port numbers.
2. A listening port shown as `127.0.0.1:5432` means what?
- It is reachable from any device on the internet
- It is reachable only from the Mac itself — Right.
- It is a Bluetooth service
- It has been blocked by the firewall
127.0.0.1 is the loopback address: connections to it can only originate from the same machine.
3. What does the macOS Application Firewall primarily control?
- Outgoing connections apps make to the internet
- Incoming connections to apps and services on the Mac — Right.
- Bluetooth pairing requests
- Which websites can be visited
The Application Firewall decides, per app, whether unsolicited incoming connections are allowed; it does not filter what apps send out.
Do it with FireAI
Put this lesson into practice on your own Mac.
- Security modes: Home, Coffee shop, Paranoid, Under attack — Match FireAI’s strictness to where your Mac actually is, in one tap.
- Find apps with known security flaws — Close known holes before anyone uses them: update the one app that needs it.
- Answer your first connection prompt, and what each lifetime means — Understand exactly what you’re approving the first time FireAI asks.
Sources
- Apple Support: Block connections to your Mac with a firewall
- Apple Support: Change Firewall settings on Mac
- Apple Support: Allow a remote computer to access your Mac (Remote Login)
- Apple Support: Set up file sharing on Mac
Put it into practice on your Mac
Try every feature free for 17 days, no card needed.