macOS Application Firewall

Also known as: Mac firewall

On this page 6

The macOS Application Firewall is the built-in Mac firewall that decides, application by application, whether software on the computer may accept incoming network connections. Within macOS security & privacy, it acts as an application-layer filter that identifies programs by their code signatures rather than by port numbers, which makes it simple to manage on a personal computer.

Apple introduced it in Mac OS X 10.5 Leopard, and it is still turned off by default on most new installations, because a typical Mac exposes few listening services. Administrators enable it in System Settings under Network, from the Terminal or through a configuration profile pushed by mobile device management.

How the application firewall filters connections

The application firewall works by intercepting inbound connection attempts at the socket layer and checking which process owns the listening socket. If that process is on the allow list, the connection proceeds; if it is on the block list, the connection is refused; if it is unknown, macOS shows a prompt asking the user to allow or deny incoming connections.

Decisions are bound to the application’s code-signing identity. A signed app keeps its rule across updates as long as the signature remains valid, while an unsigned or modified binary loses trust and triggers a new prompt. The filter covers incoming traffic only: outgoing connections are never inspected or blocked.

Stealth mode deserves a precise description. With it enabled, the Mac does not answer ICMP echo requests and silently drops connection attempts to closed TCP and UDP ports instead of returning a reset or an unreachable message. Port scanners therefore cannot easily confirm that the host exists, although open services still respond to allowed clients.

The settings below shape how strict the firewall is.

OptionEffectWhen to use
Block all incoming connectionsRefuses all inbound connections except essential servicesPublic networks and travel
Allow built-in software automaticallyTrusts Apple-signed system componentsDefault for most users
Allow downloaded signed software automaticallyTrusts apps signed with a valid Developer IDConvenience on personal Macs
Enable stealth modeIgnores pings and probes to closed portsReducing network visibility
Per-app rulesExplicit allow or block for named appsFine control on managed devices
Firewall options and their effect

Application firewall versus the packet filter

macOS contains a second, independent firewall: PF, the packet filter inherited from OpenBSD and controlled with the pfctl command. PF works on addresses, ports and protocols in both directions, while the application firewall works on application identity for inbound traffic. Both can run at the same time, and a connection must pass both.

AspectApplication firewallPacket filter (PF)
Decision basisCode signature of the listening appIP address, port and protocol
DirectionInbound onlyInbound and outbound
InterfaceSystem Settings, socketfilterfw, profilespfctl and configuration files
PersistenceManaged automaticallyRequires launch daemons for custom rules
Typical userEveryoneAdvanced administrators
Comparison of macOS firewall layers

The application firewall also complements other layers in the Topic. Gatekeeper and notarization decide whether an app may run at all, while the firewall decides whether a running app may accept network clients. Together with System Integrity Protection, which shields the firewall’s own components from tampering, these controls form a layered defense rather than a single barrier.

For most organizations the application firewall is the practical baseline, while PF suits servers or lab machines that need network-level rules. Outbound filtering, which many users expect from a firewall, requires a third-party network extension built on Apple’s content filter frameworks.

Managing the firewall from Terminal and profiles

The command-line tool socketfilterfw, located in /usr/libexec/ApplicationFirewall, offers full scripted control of the firewall and is useful for audits and remote management. Changes require administrator rights.

CommandPurpose
–getglobalstateShows whether the firewall is on
–setglobalstate onTurns the firewall on
–setstealthmode onEnables stealth mode
–setblockall onBlocks all incoming connections
–listappsLists apps and their rules
–add and –blockappAdds an app and blocks it
Useful socketfilterfw commands

On managed fleets, the firewall payload in a configuration profile enforces the global state, stealth mode and block-all setting, and it can lock the settings so users cannot turn the firewall off. Compliance frameworks such as the CIS benchmarks for macOS expect the firewall and stealth mode to be enabled.

Limitations and common mistakes

The application firewall is a useful but narrow control, and misunderstanding its scope leads to false confidence. It reduces exposure of listening services; it does not stop malware from sending data out of the Mac.

  • Expecting outbound protection: data exfiltration and command-and-control traffic pass freely through the application firewall.
  • Clicking allow on every prompt: users who approve unknown apps quickly train the firewall to trust anything.
  • Assuming block all is absolute: essential services such as DHCP, Bonjour and IPsec still work so the Mac remains connected.
  • Forgetting modified apps: tools that alter an app bundle break its signature, causing repeated prompts or silent blocking.
  • Conflicting rules with PF: a custom PF rule can block traffic that the application firewall allows, which makes troubleshooting confusing.

Another frequent oversight is relying on the firewall to protect services that were never needed. Disabling unused sharing services, such as screen sharing or remote login, removes the listening socket entirely, which is stronger than any firewall rule applied to it.

When a service stops accepting connections, administrators should check both firewall layers and the unified log, where firewall events are recorded, before changing application settings.

Explained without jargon

Think of the Mac as an office building and every app as a person working inside it. The macOS Application Firewall is the receptionist at the front door. When a visitor arrives from the network asking for a particular app, the receptionist checks whether that app is allowed to receive visitors.

Known and trusted apps get their visitors sent straight through; unknown apps cause the receptionist to ask you first. The receptionist only watches who comes in, though, not who leaves, so it is one layer of protection among several, not a complete security system.

A typical use case

A freelance video editor often works from airports and coworking spaces on public Wi-Fi. Her MacBook runs a media server app for sharing previews with clients at home, and she has enabled file sharing for transfers to a second machine. On an untrusted network, both services would be visible to every device on the same Wi-Fi.

She turns on the macOS Application Firewall with stealth mode enabled and, while traveling, switches on the option to block all incoming connections. Network scanners in the coworking space now receive no response from her laptop, and the media server cannot be reached from outside. Back at her studio, she switches block-all off, and the firewall’s existing per-app rules let the trusted services work again without any further configuration.