I need to toggle back and forth between engaging and disengaging a socks proxy within Safari:

Next open safari and click on "safari" in the top left menu bar to open the drop down menu and then click on preferences. You can do the same thing by pressing CMD+,. Click on the advanced tab and find "Proxies", click "Change Settings". System Preferences should open and you can now select "SOCKS Proxy". You should be setup and if you check google for your IP it should be masked by the address that you're SSH'd into. Note this is system wide and will cover all network communications. You can turn this off by unselecting the SOCKS Proxy.

Is it possible to perform this task with a script? Bonus round: add button or menu item to Safari UI to execute proxy toggle. Any feedback to clarify question is appreciated.

1 Answer 1


To turn on SOCKS proxy for the network service called Wi-Fi, run

networksetup -setsocksfirewallproxystate Wi-Fi on

Replace ‘Wi-Fi’ with the name of your network service.
Replace ‘on’ with ‘off’ to turn off the proxy.

  • 1
    How would this be scripted to: If setsocksfirewallproxystate is not on then set to on else set to off?
    – gatorback
    Commented Jan 14, 2018 at 18:53
  • 1
    @gatorback 3 years late but networksetup -getsocksfirewallproxy Wi-Fi prints the current SOCKS proxy state and related info
    – ZomoXYZ
    Commented Feb 25, 2022 at 17:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .