LightAtom

Mac Firewall Settings: Turn It On, Stealth Mode, App Rules

macOS has a built-in application firewall for incoming connections. Here's how to turn it on, use stealth mode and per-app rules, and what to use for outgoing traffic.

/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate

Show whether the firewall is on.

beginner5 minNeeds: Administrator account

When to use it

Turn the firewall on if you use public Wi-Fi, run apps that open ports (development servers, file sharing), or just want fewer services reachable. It's off by default on macOS, because a fresh Mac has no services listening to the network anyway.

Steps

  1. Turn it on

    System Settings › Network › Firewall, then switch it on.
  2. Open the options

    Click Options… to see app rules and the global switches.
  3. Enable stealth mode

    Enable stealth mode stops the Mac answering pings and probes to closed ports, so it's less visible on a network.
  4. Set rules per app

    Click + to add an app and choose Allow incoming connections or Block incoming connections. macOS also asks the first time an unsigned app wants to listen.
  5. Check from Terminal

    The same settings are available with socketfilterfw.
    /usr/libexec/ApplicationFirewall/socketfilterfw --getstealthmode

Output explained

$ /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
Firewall is disabled. (State = 0)
$ /usr/libexec/ApplicationFirewall/socketfilterfw --getstealthmode
Firewall stealth mode is off
$ /usr/libexec/ApplicationFirewall/socketfilterfw --getblockall
Firewall has block all state set to disabled.

State 0 is off, 1 is on, and 2 is on with Block all incoming connections, which allows only essential services (DHCP, Bonjour, IPsec). That mode also stops AirDrop, file sharing and screen sharing from receiving connections.

Options and variations

FlagMeaningExample
--getglobalstate / --setglobalstate on|offFirewall on or offsudo …/socketfilterfw --setglobalstate on
--setstealthmode on|offDon't answer probes or pingssudo …/socketfilterfw --setstealthmode on
--setblockall on|offBlock all incoming connectionssudo …/socketfilterfw --setblockall on
--add PATH / --blockapp PATHAdd an app / block its incoming connectionssudo …/socketfilterfw --blockapp /Applications/App.app
--listappsShow app rules…/socketfilterfw --listapps

Common errors

ErrorCauseFix
AirDrop stopped workingBlock all incoming connections is onTurn it off in Firewall Options.
An app still connects outThe built-in firewall only filters incoming connectionsUse an outbound firewall like LuLu or Little Snitch.
Dev server unreachable from phoneThe firewall blocks the app (node, python)Allow it in Options, or when macOS prompts.

Do it in the app

The firewall decides who may connect in; LightAtom's Ports view shows which apps are listening and whether each port is reachable from the network or only localhost, so you know what the firewall is protecting.

Frequently asked questions

Does a Mac have a firewall?

Yes. macOS includes an application firewall for incoming connections, off by default. Turn it on in System Settings › Network › Firewall.

Should I turn on the Mac firewall?

It's a good idea on laptops that join public Wi-Fi and on Macs that run sharing or development servers. It has little downside: allowed apps keep working.

What does stealth mode do on a Mac?

The Mac stops responding to pings and to connection attempts on closed ports, so network scans see less of it. Allowed services still answer.

How do I block an app from the internet on a Mac?

The built-in firewall only blocks incoming connections. To block an app's outgoing connections, use an outbound firewall such as LuLu (free) or Little Snitch.

Is the Mac firewall the same as pf?

No. The application firewall works per app. pf (pfctl) is a lower-level packet filter that works on addresses and ports; macOS uses it internally and you can configure it for advanced rules.

LightAtom team

The people who build LightAtom, a network monitor for macOS.