10

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?

3
  • On macOS: - brew install tor - echo "SocksPort 9050" > /usr/local/etc/tor/torrc - brew services start tor
    – Dorian
    Oct 29, 2016 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, 2016 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, 2018 at 9:38

2 Answers 2

8

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.

2
  • 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, 2014 at 23:20
  • 1
    Also on modern curl you can use -x socks5h://127.0.0.1:9050/
    – cacahuatl
    Oct 30, 2016 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.

You must log in to answer this question.

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