Change Firewall preferences on Mac
Use the Firewall pane of Security & Privacy preferences to turn on the firewall in macOS to prevent unwanted connections from the internet or other networks. Learn how to block connections to your Mac with a firewall.
To change these preferences on your Mac, choose Apple menu > System Preferences, click Security & Privacy , then click Firewall.
Note: If the lock at the bottom left of the pane is locked , click it to unlock the preference pane.
Turn On Firewall
Prevent unwanted connections from the internet or other networks.
Choose how much to block incoming connections.
Block all incoming connections
Prevent incoming connections to nonessential services and apps.
Basic internet services are a set of apps that allow your Mac to find services provided by other computers on the network. This setting prevents connections to all other sharing services.
Add an app or service to allow incoming connections.
Remove an app or service from allowing incoming connections.
Automatically allow built-in software to receive incoming connections
Automatically allow downloaded signed software to receive incoming connections
Allow downloaded apps and services that are signed by a valid certificate authority to be automatically added to the list of allowed apps, without your authorization.
Enable stealth mode
Prevent your Mac from responding to probing requests that can be used to reveal its existence. The Mac still answers requests from authorized apps, but unauthorized requests such as ICMP (ping) get no response.
Increase the security on your Mac by automatically logging out after a period of inactivity and limiting access to system-wide preferences.
Certain shared services can connect through the firewall when they are turned on in Sharing preferences. For additional security, you can prevent connections to these incoming services by turning off the service in Sharing preferences. See Share your Mac screen, files, and services with other users on your network.