7

I installed a tor relay on debian wheezy and it runs fine. Now I want to use curl and I used:

curl --socks5 127.0.0.1:9150 http://www.torproject.org

But it couldn't connect to the host.

If I start the tor-browser-bundle it works.

How can I do it without the bundle?

  • On macOS: - brew install tor - echo "SocksPort 9050" > /usr/local/etc/tor/torrc - brew services start tor – Dorian Oct 29 '16 at 21:46
  • The question is specifically about Debian? Also you don't need to define SocksPort 9050, if it's not defined it will default to that setting. – cacahuatl Oct 30 '16 at 1:20
  • for the url here check.torproject.org gives feedback if successful so you can grep content for e.g. either "Sorry." or "Congratulations." in a script. – vv01f Apr 15 '18 at 9:38
6

The main problem seems the port you are using. According to your command you're using port 9150 which is used by Tor Browser Bundle. If the bundle is closed, this port is not open.

In the default configuration Tor uses port 9050 as SocksPort:

curl --socks5-hostname 127.0.0.1:9050 https://www.torproject.org/

or

curl -x socks5h://127.0.0.1:9050/ https://www.torproject.org/

Your torrc should contain the following line:

SocksPort 9050

This enables the port which Tor uses for SOCKS connections and what is used with the command above.

  • Maybe you can try to replace <i>--socks5</i> by <i>--socks5-hostname</i> (the proxy resolve the hostname). Or you can use the <i>torify</i> command. – gapz Feb 23 '14 at 23:20
  • 1
    Also on modern curl you can use -x socks5h://127.0.0.1:9050/ – cacahuatl Oct 30 '16 at 1:19
2

a tor relay

This may not be running as a Tor node you can connect on. If Tor is installed you should be able to run it on the command line with no other options:

tor

Then test with the curl command you have above:

curl --socks5 127.0.0.1:9150 http://www.torproject.org

In the console window you ran tor in you should see information about the Tor circuit and connections. Leave it open for up to 2 minutes and see if it outputs a message about the timeout. If the message says "waiting for info" then the SOCKS5 ports are likely wrong.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.