How to block an app from the internet on your Mac
Maybe a tool phones home with usage data you didn’t agree to. Maybe you want to test how your own app behaves offline without turning off Wi-Fi for everything else. Or you want an old app you trust to keep working, but never update itself again. Each of these comes down to the same question: how do you stop one app on your Mac from connecting to the internet?
macOS doesn’t have a switch for this. It has a few tools that get partway there, and it helps to know what each one can and can’t do before you rely on it.
The macOS firewall blocks incoming connections only
The first place most people look is System Settings › Network › Firewall. Turn it on, click Options…, add an app and set it to Block incoming connections.
That stops other computers from connecting to the app, for example to a server it runs. It does nothing about connections the app makes out to the internet. An app set to “Block incoming connections” can still check for updates, sync and send analytics.
The firewall is still worth turning on, especially on laptops that join public Wi-Fi. It just isn’t a way to cut an app off.
Block a domain with /etc/hosts
If you know the domain an app connects to, you can point it at an address that goes nowhere. The /etc/hosts file maps names to addresses before DNS is asked, for every app on your Mac.
Open it with administrator rights:
sudo nano /etc/hosts
Add a line for each domain at the end, save with Control-O and quit with Control-X:
0.0.0.0 telemetry.example.com
Then clear the DNS cache so the change applies right away:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
To undo it, delete the line and clear the cache again.
This works well for one or two domains, with limits:
- It blocks the domain for every app, not just the one you had in mind. Block a domain that your browser or another tool also uses, and they lose it too.
- Exact names only.
/etc/hostshas no wildcards. Blockingexample.comdoesn’t blockapi.example.com. - Apps can go around it. An app that connects to an IP address directly, or uses its own DNS such as DNS over HTTPS, never reads
/etc/hosts. - You need to know the domains first. Seeing which ones an app uses is the hard part. How to see which apps connect to the internet on your Mac covers that.
Packet filter (pf): addresses, not apps
macOS includes pf, the packet filter from BSD. It can block traffic to specific IP addresses or ports for the whole Mac. It is powerful, but a poor fit here:
- It knows addresses and ports, not apps or domains. It can’t tell Slack’s connections from Safari’s.
- The addresses behind a domain change, and big services use hundreds of them.
- Rules you load by hand are gone after a restart, and editing
/etc/pf.confwrongly can cut off all networking or be undone by a macOS update.
Unless you already use pf for something else, skip it for blocking apps.
What blocking one app really takes
To block one app and leave the others alone, something has to look at each connection as it starts and ask: which app is this, and where is it going? On macOS, that is what a content filter network extension does. Apple provides it so apps can see and allow or block connections per app, and macOS asks you to approve it once before it can run.
It is the way Apple supports for filtering connections per app on current macOS, so tools that do this well are built on it. What sets them apart is how clearly they show you what is happening.
Caveats
- Blocking can break things. Many apps check their license, sign you in or fetch content over the same domains. Block one app at a time, check that it still does what you need, and keep notes on what you blocked.
- Updates stop too. If you block an app’s update domain, you also stop getting its security fixes.
- Some traffic runs through macOS. Push notifications and some background downloads go through system processes, not the app itself, so per-app rules for the app don’t catch them.
- Other network tools. VPNs and other filtering apps also handle your Mac’s connections. Test your setup if you run more than one.
The faster way: CCToolify
The Network tool in CCToolify lists every connection by app, and each domain has an Allow / Block control right next to it.
- Block a domain for one app. The same domain stays available to your other apps.
- Block all traffic blocks every domain an app uses and its future connections. Connections to this Mac stay allowed, so your local dev servers keep working.
- Ask before new connections is optional: you get a prompt the first time an app connects to a new domain, and choose Allow or Block. If you don’t answer, the connection is allowed.
- Rules apply right away, and keep applying when you pause recording.
- CCToolify sees which app connects, the domain, the address, the port and sizes. It never reads what is inside your connections, and nothing leaves your Mac.
After the free trial, Block and Ask need a license. Without one, block rules are not enforced and all traffic is allowed; they apply again as soon as you activate a license.
The Network guide covers rules and settings in detail.