Torify and Torsocks not working

Solution 1:

After spending lot of time and energy, I finally could manage to solve the problem myself.

It seems by default, Tor should be set in such a way to use the port 9050 for socks5. This setting can be found in /etc/tor/torsocks.conf file. Look at these lines in this file:

# Default Tor address and port. By default, Tor will listen on localhost for
# any SOCKS connection and relay the traffic on the Tor network.
TorAddress 127.0.0.1
TorPort 9050

Based on my TorBrowser setting, the browser uses port 9150 instead of 9050. So, I changed the relevant line and set 9150 as the port.

Now, torsocks and torify work as expected.
(Just it seems there is some technical issue with ifconfig.me website, since I cannot open it even in browser. But other websites are working well.)

Solution 2:

had this happen to me and also figured out what caused it: the tor port was left in a close_wait state after running a script with torify which means the port can't be opened for a short while so torify will not work until that port is released from close_wait