How to Check the macOS Firewall Status Using Terminal

Illustration for How to Check the macOS Firewall Status Using Terminal

Quick Answer

To check whether the macOS firewall is turned on, open Terminal and run:

/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate

If the firewall is enabled, Terminal reports:

Firewall is enabled. (State = 1)

If it is disabled, you’ll see:

Firewall is disabled. (State = 0)

This command checks the built-in macOS Application Firewall, which controls incoming connections to apps and services. It does not show every network security feature on your Mac, and it does not tell you whether an app can access the internet.

What the macOS Firewall Does

The macOS Application Firewall helps control incoming network connections. When an app or service tries to accept an incoming connection, the firewall can allow or block it based on your settings.

This is different from:

  • Outgoing network access: Whether an app can connect to websites or other internet services.
  • Wi-Fi security: The encryption and password protection used by your wireless network.
  • Privacy permissions: Whether an app can access files, your camera, microphone, location, or other data.
  • A network firewall: A firewall built into a router, business network, or third-party security product.

The Terminal command in this guide reports the status of the built-in macOS Application Firewall.

Important: A firewall status check does not prove that your Mac is completely protected. It only reports whether the Application Firewall is enabled.

Check the Firewall Status in Terminal

Terminal is included with macOS and lets you run commands directly. The command below only reads the firewall’s global status; it does not change your settings.

1. Open Terminal

You can open Terminal in either of these ways:

  1. Press Command-Space to open Spotlight.
  2. Type Terminal.
  3. Press Return.

Alternatively, open Finder, select Applications, open Utilities, and then double-click Terminal.

2. Run the status command

Copy and paste this command into Terminal:

/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate

Press Return.

3. Read the result

Terminal should display one of these results:

Firewall is enabled. (State = 1)

or:

Firewall is disabled. (State = 0)

The result means:

  • State = 1: The Application Firewall is enabled.
  • State = 0: The Application Firewall is disabled.

You may also see additional information depending on your macOS configuration, but the enabled or disabled line is the important part.

Check Additional Firewall Settings

The global-state command tells you whether the firewall is on or off. You can also inspect related settings with the same utility.

Check whether signed applications are automatically allowed

Run:

/usr/libexec/ApplicationFirewall/socketfilterfw --getallowsigned

This reports whether macOS automatically allows incoming connections for applications signed by a trusted certificate authority.

Possible output may indicate that signed applications are allowed or not allowed.

This setting can affect how macOS handles trusted apps, but it does not replace the main firewall status check.

Check whether the firewall automatically allows downloaded signed apps

Run:

/usr/libexec/ApplicationFirewall/socketfilterfw --getstealthmode

Despite the command name, this checks Stealth Mode, not automatic approval of downloaded apps. Stealth Mode determines whether your Mac responds to certain unsolicited network requests, such as probing requests that do not come from an established connection.

You can also check other Application Firewall settings with:

/usr/libexec/ApplicationFirewall/socketfilterfw --getblockall

This reports whether the firewall is configured to block all incoming connections, subject to essential services and other system rules.

Note: The exact wording of Terminal’s output can vary. Focus on the setting name and whether it is reported as enabled or disabled.

Display the Firewall Configuration

To review the Application Firewall’s broader configuration, run:

/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
/usr/libexec/ApplicationFirewall/socketfilterfw --getblockall
/usr/libexec/ApplicationFirewall/socketfilterfw --getstealthmode
/usr/libexec/ApplicationFirewall/socketfilterfw --getallowsigned

These commands only display settings. They do not enable or disable the firewall and do not modify app rules.

Running them together can make it easier to review the main configuration in one place:

  • Global firewall state
  • Whether all incoming connections are blocked
  • Stealth Mode status
  • Whether signed applications are automatically allowed

If you only need a quick answer, use the first command by itself.

Check the Firewall Through System Settings

Terminal is useful when you are troubleshooting, working remotely, or prefer command-line tools. You can also confirm the setting in the macOS interface.

  1. Open the Apple menu in the upper-left corner.
  2. Select System Settings.
  3. Select Network in the sidebar.
  4. Click Firewall.
  5. Review the firewall switch or status.

On some Mac configurations, you may need to scroll in the sidebar or use the search field in System Settings to find Firewall.

The Terminal command and the Firewall pane should agree about whether the Application Firewall is enabled. If they appear to disagree, restart System Settings and run the Terminal command again.

For instructions on enabling the firewall and adjusting its app access rules, see How to Turn On and Configure the Firewall on Mac.

What to Do If the Firewall Is Disabled

If Terminal reports:

Firewall is disabled. (State = 0)

you can enable the firewall from System Settings:

  1. Open the Apple menu and select System Settings.
  2. Select Network.
  3. Select Firewall.
  4. Turn on the firewall switch.

macOS may require administrator authentication before allowing the change. Enter an administrator password or use Touch ID if prompted.

You can also enable the Application Firewall from Terminal, but this changes system behavior and may affect incoming connections. Before running a command that modifies firewall settings, close or save work in apps that depend on network connections.

To enable the firewall from Terminal:

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on

Press Return, enter an administrator password when prompted, and press Return again. Terminal does not display characters while you type the password. This is normal.

To turn the firewall off again, use:

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off

Warning: Turning off the firewall reduces protection against unsolicited incoming connections. Use the off command only when you have a specific reason, such as troubleshooting, and turn the firewall back on afterward.

You can verify the result with:

/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate

Understand Firewall Rules and App Access

The Application Firewall can maintain rules for individual apps and services. To display the current rules, run:

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --listapps

Because this command may require access to protected system information, macOS can ask for administrator authentication.

The output may include applications and whether each one is allowed or blocked. Depending on the app and system configuration, the list can be lengthy.

To add an application to the firewall list, use:

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add /path/to/Application.app

Replace /path/to/Application.app with the actual path to an app. For example:

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add "/Applications/Example.app"

To allow an app:

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --unblockapp "/Applications/Example.app"

To block an app:

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --blockapp "/Applications/Example.app"

These commands change firewall behavior. Confirm the application path carefully before running them, and avoid changing rules for system components unless you understand the effect.

You can usually manage the same app rules more safely in System Settings > Network > Firewall > Options, where available. The graphical interface makes it easier to confirm which application you are changing.

Troubleshooting

Terminal says the command cannot be found

Use the full path exactly as shown:

/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate

Do not omit /usr/libexec/ApplicationFirewall/ or replace socketfilterfw with a similarly named command.

Terminal reports “Permission denied”

The basic status command normally does not require sudo. If you are trying to list or change firewall rules, macOS may require administrator privileges. For those commands, place sudo at the beginning:

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --listapps

Only use sudo when necessary. It gives the command elevated privileges, so check the command before pressing Return.

The status changes back after a restart

If the firewall repeatedly turns off, check whether:

  • A third-party security or network-management tool is controlling firewall settings.
  • A work or school administrator manages the Mac.
  • Another user with administrator access changed the setting.
  • A system configuration issue is preventing the setting from being saved.

If the Mac is managed by an organization, you may not be able to change the firewall yourself.

An app still cannot connect

The Application Firewall primarily controls incoming connections. If an app cannot connect to the internet, the cause may instead be:

  • A Wi-Fi or Ethernet problem
  • A VPN
  • A proxy
  • A router or network firewall
  • An app-specific connection error
  • A privacy permission
  • A server outage

Turning off the firewall is not a reliable general-purpose fix for internet connection problems. Check the app’s own settings and your network configuration first.

An app works only when the firewall is disabled

The app may need permission to accept incoming connections. Open System Settings > Network > Firewall, select the firewall options, and review the app’s access rule.

If you use Terminal, list the configured applications:

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --listapps

Avoid permanently disabling the firewall just to make one application work. A specific allow rule is generally easier to review and reverse.

Terminal shows unexpected output

The command-line utility can display different wording or additional lines depending on the macOS release and configuration. Look for the main result:

  • State = 1 means enabled.
  • State = 0 means disabled.

If the output is unclear, confirm the status in System Settings > Network > Firewall.

Frequently Asked Questions

Is the macOS firewall enabled by default?

The initial configuration can vary by Mac and setup. Do not assume its status. Run:

/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate

to check the current setting.

Does the firewall protect against malware?

The Application Firewall helps control incoming connections, but it is not a complete malware protection system. Keep macOS and apps updated, install software carefully, and review unexpected security prompts.

Does the firewall block websites?

Usually, no. The Application Firewall is designed mainly to control incoming connections to apps and services. It is not a website filter or a general tool for blocking outgoing internet traffic.

Can I check the firewall without administrator access?

Yes. The basic global-status command generally works without sudo:

/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate

Administrator authentication may be required to view some details or change settings.

What is the difference between the firewall and Stealth Mode?

The firewall controls whether applications and services can accept incoming connections. Stealth Mode changes how your Mac responds to certain unsolicited network requests. They are related settings, but they are not the same thing.

How do I turn the firewall back on after testing?

Run:

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on

Then verify it:

/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate

Can I use this command on another Mac over SSH?

Yes, if remote Terminal access is already configured and your account has permission to connect. However, changing firewall settings remotely can interrupt network access, so verify the command carefully before using sudo.

Final Thoughts

The fastest way to check the macOS firewall status is:

/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate

State = 1 means the Application Firewall is enabled, while State = 0 means it is disabled. Use the additional commands only when you need to inspect firewall rules or settings, and be cautious with commands that change system behavior.