Skip to content
← All posts

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:

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:

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

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.

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.