I want to Tor in terminal. This is what I used to do and it was working without any issue:

  • running Tor Browser
  • running torify or torsocks before the command in terminal

But it is for a while that this is not working. I don't remember if this is happening after some specific change in my system or not. I haven't had any major and noticeable change in it.

Perhaps the following lines can help for knowing the issue:

$ curl ifconfig.me
111.222.333.444       <<< My real IP

$ torify curl ifconfig.me 2> /dev/null 

$ torify curl ifconfig.me
[Jan 21 20:55:05] PERROR torsocks[16007]: socks5 libc connect: Connection refused (in socks5_connect() at socks5.c:185)

$ torsocks curl ifconfig.me
[Jan 21 20:59:50] ERROR torsocks[16100]: Unable to resolve. Status reply: 4 (in socks5_recv_resolve_reply() at socks5.c:666)
curl: (6) Could not resolve host: ifconfig.me

While I'm facing this issue, I can easily use Tor Browser with no problem.

Any idea how to solve this issue?

2 Answers 2


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.
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.)

  • Did you change torrc file or torsocks.conf? for Torsocks.conf shows 9150 as the TorPort but still the exact same error as you had.
    – rowman
    Jan 6, 2018 at 9:35
  • Do you use TorBrowser or Tor service? Jan 6, 2018 at 11:43
  • I have TorBrowser which is working fine, but I can not use torsocks. I have tor service running
    – rowman
    Jan 9, 2018 at 5:02
  • Have you tried to change TorPort to 9050? Jan 11, 2018 at 9:27
  • 2
    You can also specify the port with option, for e.g.: torsocks -P 9150 curl https://ipinfo.io/json
    – rmalviya
    Sep 19, 2020 at 17:03

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

You must log in to answer this question.

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