How to open firewall from terminal I am developing a go app on a server(mac-mini) where I connect via ssh. I  restart the app many times: go run main.go
Problem is, that I dont have access to the graphical ui - &quot;Firewall Options...&quot;.
I really like to have the firewall on for security reason and poke minimal holes in it only when needed.
Is there any way to set and allow a port to be open, for incoming connections from the terminal?
Configure the firewall to be permissible for selected applications and services.

To turn the firewall on for specific applications/services :
sudo defaults write /Library/Preferences/com.apple.alf globalstate -int 1


https://raymii.org/s/snippets/OS_X_-_Turn_firewall_on_or_off_from_the_command_line.html
Reboot for the change to take effect.

/usr/libexec/ApplicationFirewall/socketfilterfw allows you to configure applications through the firewall. The tool provides its own help and documentation.
For example, to grant an application incoming connections, you can use
./socketfilterfw -t &quot;/Applications/Foo.app/Contents/MacOS/Foo&quot;