Simple Tor setup on macOS
There are many reasons you might want to browse anonymously which can be accomplished by using Tor. The setup instructions on Tor’s website are quite scattered and outdated so here are some steps to setup Tor on macOS with a simple automated script at the end.
I’m using macOS High Sierra (10.13) for the following instructions but it should work on almost any macOS version.
- Tor Browser
- Install Tor
- Set network proxy settings via System Preferences
- All in one go: start Tor & set network proxy settings automatically
- Non-standard apps
The most simple way to surf anonymously with Tor is to just grab Tor Browser. It’s a modified version of Firefox Extended Support Release (ESR) with Tor and some extensions (Torbutton, TorLauncher, NoScript, and HTTPS-Everywhere) built right in. Upon start, Tor Browser automatically starts the required Tor background processes and routes traffic through the Tor network. That’s the way to go if you want the highest level of protection without much further configuration.
But it’s based on an old version of Firefox and there might be more you want to do anonymously on your machine than just browsing the web, like accessing resources via the Terminal or any other app. Or just use the browser you’re used to.
For this you need to have Tor installed on your system and additionally set specific proxy values in your network preferences after you’ve started Tor.
Be aware that the instructions and the script mentioned below will not make whatever you do on the web anonymous. Much depends on your browsing habits, what apps you're using, and none of the methods below will offer the same level of protection than Tor Browser out of the box. You have been warned.
In your Terminal execute:
brew install tor
Then you can start it up by running:
Congratulations, you now have Tor running on your system. But none of your network traffic is routed through it yet.
In order for all your system traffic being routed through Tor you need to adjust your system’s network proxy settings which you can either do visually in the System Preferences or programmatically via macOS’s builtin
You can do this under System Preferences > Network by creating a specific Tor network location for it:
From Location dropdown at the top, select Edit Locations…
Create a new location by hitting the plus button and name it Tor. Hitting Done will select the new location which is now ready to be configured.
Go to Advanced > Proxies and activate SOCKS Proxy and add those values:
SOCKS proxy server:
After hitting OK & Apply at the initial network screen, you can easily switch to this newly created location from your menu bar under > Location whenever you start up Tor.
Switching to the Tor location routes all network traffic on your system through Tor. Note that you have to repeat those steps for every other network interface if you use, say, Wi-Fi and Ethernet interchangeably.
When you’re already in the Terminal to start up Tor, additionally setting the network settings involves a lot of fiddling around. Ain’t nobody got time for that.
Thankfully macOS provides a way to programmatically set those proxy values via the
networksetup utility. I’ve found a nice script for this but running it opened multiple admin password prompts. So I extended it a bit to make it more user friendly.
In a nutshell, this shell script asks you for your admin password upfront, starts up Tor, and sets all required proxy network settings automatically:
#!/usr/bin/env bash# 'Wi-Fi' or 'Ethernet' or 'Display Ethernet'INTERFACE=Wi-Fi# Ask for the administrator password upfrontsudo -v# Keep-alive: update existing `sudo` time stamp until finished2>/dev/null &# trap ctrl-c and call disable_proxy()trap disable_proxy INT# Let's rollsudo networksetup -setsocksfirewallproxy $INTERFACE 127.0.0.1 9050 offsudo networksetup -setsocksfirewallproxystate $INTERFACE onecho "$(tput setaf 64)" # greenecho "SOCKS proxy 127.0.0.1:9050 enabled."echo "$(tput setaf 136)" # orangeecho "Starting Tor..."echo "$(tput sgr0)" # color resettor
Save this script under something like
tor.sh in one of your sourced
bin folders, make it executable with
chmod + x and use it as a replacement for the general
tor command. So you can just run
and Tor should run smoothly on your system without additional configuration:
Verify you’re indeed browsing over the Tor network by going to check.torproject.org.
When you’re done, just exit the script with ctrl + c and the network settings will be reverted to their previous configuration.
Some apps are just not good Mac citizens and use their own network settings, ignoring macOS system network proxy settings. E.g. older versions of Google Chrome were using their own custom network settings and therefore were not routing their web traffic through the proxy configured in System Preferences.
But the most recent Chrome version automatically picks up macOS’s native proxy settings, as does the most recent version of Firefox.
Always check your Tor connection with whatever app you’re using and if needed set the proxy preferences manually in the respective app with:
- SOCKS proxy server: