I can’t get Torsocks to work properly on macOS 12.3 Monterey, while it works perfectly on Raspbian 11 Bullseye. The program seems to work, but it doesn’t torify the traffic. The version is Torsocks 2.3.0 on both systems.
To do the test, I use the same command twice, with and without Torsocks. This command queries the torproject.org API and returns a flag that indicates whether the traffic is torified and the public IP address:
wget -qO- https://check.torproject.org/api/ip | xargs echo
torsocks wget -qO- https://check.torproject.org/api/ip | xargs echo
On Raspbian, I get the expected results:
{IsTor:false,IP:111.111.11.11}
{IsTor:true,IP:222.222.22.22}
While on macOS, the results are the same with or without Torsocks:
{IsTor:false,IP:111.111.11.11}
{IsTor:false,IP:111.111.11.11}
I also used Wireshark with the filter
ip.addr == 116.202.120.181
and the result is consistent, i.e. Wireshark does not detect traffic to this IP when Torsocks is used on Raspbian, but it still detects it on macOS.
I also tried with the Tor service started, but without success:
brew install tor
brew services restart tor
brew services list
Notes
Tor installation
I installed Torsocks in the following way:
On macOS
brew install torsocks
On Raspbian
sudo apt-get install -y torsocks
Other unsuccessful attempts
As suggested on this page, I also tried to use the homebrew version of curl:
torsocks /opt/homebrew/Cellar/curl/7.83.0/bin/curl https://check.torproject.org/api/ip
And also the homebrew version of wget:
torsocks /opt/homebrew/Cellar/wget/1.21.3/bin/wget -qO- https://check.torproject.org/api/ip | xargs echo
Note that the version of curl that ships with macOS is protected and does not work with Torsocks:
torsocks curl https://check.torproject.org/api/ip
ERROR: /usr/bin/curl is located in a directory protected by Apple's System Integrity Protection.
I also tried to use port 9150 instead of the default 9050 as suggested here:
torsocks --port 9150 -d wget -qO- https://check.torproject.org/api/ip | xargs echo
Note that the -d
flag is very useful to see what is going on under the hood and to check where the configuration file is located.
macOS
/opt/homebrew/Cellar/torsocks/2.3.0/etc/tor/torsocks.conf
Raspbian
/etc/tor/torsocks.conf
Edit 2022-05-22
I tried to install httpie as explained here, but without success.
pip install httpie
Edit 2023-05-19
I didn’t find a way to make Torsocks works under macOS 12 and 13, but a workaround is to use programs that can be configured to use Socks5 Proxies. For example, curl
can do this. You can connect to the tor
proxy on port 9050 or the Tor Browser proxy on port 9150 (Tor Browser must be running).
curl --proxy socks5h://localhost:9150 https://check.torproject.org/api/ip
# {IsTor:true,IP:222.222.22.22}