Skip to content

Tons of Socks5() connect to x.x.x.x:8333 failed: connection refused-messages when i use TOR - why? #29759

Closed

Description

@kosuodhmwa

Is there an existing issue for this?

  • I have searched the existing issues

Current behaviour

Gets tons of Socks5() connect to x.x.x.x:8333 failed: connection refused-messages

Expected behaviour

No messages like that

Steps to reproduce

  • install tor via apt-get

  • add that to /etc/tor/torrc file:
    ControlPort 9051
    CookieAuthentication 1
    CookieAuthFileGroupReadable 1

  • restart tor service

  • add that to ~/.bitcoin/bitcoin.conf file:
    proxy=127.0.0.1:9050
    listen=1
    bind=127.0.0.1

  • start bitcoind service

Relevant log output

Many lines like that:

Socks5() connect to x.x.x.x:8333 failed: connection refused

How did you obtain Bitcoin Core

Compiled from source

What version of Bitcoin Core are you using?

Most current

Operating system and version

Debian 12.5.x

Machine specifications

Oracle VirtualBox VM, Debian 12.5.x on Windows 10 Pro x64 Host System

Activity

  1. kosuodhmwa commented on Mar 28, 2024

    @kosuodhmwa
    Author

    Installed as described on https://en.bitcoin.it/wiki/Setting_up_a_Tor_hidden_service AND

    1.) "usermod -a -G debian-tor BITCOIN_USER" instead of "usermod -a -G tor BITCOIN_USER"

    2.) Then a OS restart after that user / group permission change thing

  2. kosuodhmwa commented on Mar 28, 2024

    @kosuodhmwa
    Author

    (BITCOIN_USER = root)

  3. kosuodhmwa commented on Mar 28, 2024

    @kosuodhmwa
    Author

    Maybe the problem is that IPv6 is disabled via sysctl.conf on that system?

  4. kosuodhmwa commented on Mar 28, 2024

    @kosuodhmwa
    Author

    Similar problem here?
    #25094

  5. kosuodhmwa commented on Mar 28, 2024

    @kosuodhmwa
    Author

    image

  6. kosuodhmwa commented on Mar 29, 2024

    @kosuodhmwa
    Author

    Nobody knows what the problem is?

  7. pinheadmz commented on Mar 29, 2024

    @pinheadmz
    Member

    What exact commit did you compile from? Does it include #29649 ?

  8. kosuodhmwa commented on Mar 29, 2024

    @kosuodhmwa
    Author

    How can i get the version number from the source i've got from master GIT repo i've compiled?

  9. pinheadmz commented on Mar 29, 2024

    @pinheadmz
    Member
  10. mzumsande commented on Apr 1, 2024

    @mzumsande
    Contributor

    I also get these errors sometimes when running with Tor. While they appear on some outgoing connection attempts, other connections are successful, so there seems to be nothing wrong on my end fundamentally. While a timout does not lead to a log entry in debug.log, answers from the SOCKS5 proxy with "general failure" and "connection refused" are logged, and it is not clear to me when which of the three happens.

    So I wonder if this happens every time and you can't make successful connections, or only sporadically (in which case the only problem might be overzealous logging).

  11. added a commit that references this issue on Apr 2, 2024
    3215d18
  12. vasild commented on Apr 2, 2024

    @vasild
    Contributor

    As @mzumsande mentioned above, some errors like these are normal because they are printed whenever we fail to connect to a Tor peer. Not all Tor peers are online all the time. Does bitcoin-cli getpeerinfo show that you have at least one outbound connection to a Tor node? With some filtering: bitcoin-cli getpeerinfo |jq 'map(select(.inbound == false and .network == "onion")) |map({connection_type: .connection_type, addr: .addr, network: .network})'.

    If you cannot establish any connection to a Tor node, then there is a real problem in your setup.

    Socks5() connect to x.x.x.x:8333 failed: connection refused

    This error comes from the Socks5 proxy (aka the Tor daemon) if it cannot connect to the destination we asked for. Do you get only IP addresses in those messages (x.x.x.x) or also onion addresses (e.g. ydvbxdzs6w5wefifiqsqntpbd7tliofenqih5hlnz34546fvy4ab7iid.onion)?

    There is an inconsistency wrt logging connection failures: IPv4 and IPv6 connection failures are logged only if running with -debug=net:

    LogPrint(BCLog::NET, "%s\n", error_message);

    LogPrint(BCLog::NET, "connection attempt to %s timed out\n", dest_str);

    whereas Tor connection failures are logged as errors unconditionally:
    LogPrintf("Socks5() connect to %s:%d failed: %s\n", strDest, port, Socks5ErrorString(pchRet2[1]));

    PS this is different from #25094 - the current issue is about errors when trying to establish outbound connections. That issue is about not being able to accept incoming connections (because we couldn't communicate properly to the Tor daemon where to redirect those incoming connections to).

  13. mzumsande commented on Apr 3, 2024

    @mzumsande
    Contributor

    For me, the Tor daemon also behaves inconsistently (Ubuntu).
    If I attempt to make a connection to one and the same non-reachable node (with addnode and onetry), I sometimes get a IntrRecvError::Timeout (which is not logged unconditionally), and sometimes get an error (Socks5() connect to x.x.x.x:8333 failed: general failure). I haven't been able to detect a pattern which of the two happens when, it looks random to me.
    From reading the code, I get the impression that the original assumption was that if the peer is not online, the Socks5 proxy returns a timeout instead of a failure - which isn't always the case for me.

  14. kosuodhmwa commented on Apr 3, 2024

    @kosuodhmwa
    Author

    The source code from the master branch i've compiled is:
    root@debian-12-btc-node:~/bitcoin# git rev-parse HEAD gives me the following output:
    0fa9f17

  15. kosuodhmwa commented on Apr 3, 2024

    @kosuodhmwa
    Author

    0fa9f17332a6d9b2eb6e3d9f9102bfd2d9c6f516

  16. kosuodhmwa commented on Apr 3, 2024

    @kosuodhmwa
    Author

    image
    Now i saw that i also have message like that:

    2024-04-03T20:43:47Z Socks5() connect to 77.7.121.181:8333 failed: general failure

    Will start "bitcoind" now with filtering for that Tor Socks5 messages: ./bitcoind | grep Socks5

  17. kosuodhmwa commented on Apr 3, 2024

    @kosuodhmwa
    Author

    "Do you get only IP addresses in those messages (x.x.x.x) or also onion addresses (e.g. ydvbxdzs6w5wefifiqsqntpbd7tliofenqih5hlnz34546fvy4ab7iid.onion)?"

    No, only for IP addresses as shown on post above. (other kind of message, but same host / ip and also same port) @vasild

  18. kosuodhmwa commented on Apr 5, 2024

    @kosuodhmwa
    Author

    sn

  19. kosuodhmwa commented on Apr 18, 2024

    @kosuodhmwa
    Author

    Maybe it's an idea to check these servers (they will be listed via console output) via "telnet [IP_ADDRESS] 8333"...

    If i dont get an anwser from telnet (TCP), then the problem is on these hosts / servers. If i get an answser, there is a problem on my side

  20. vasild commented on May 8, 2024

    @vasild
    Contributor

    There is an inconsistency wrt logging connection failures...

    Addressed in #30064

  21. kosuodhmwa commented on May 8, 2024

    @kosuodhmwa
    Author

    ok thx

  22. kosuodhmwa commented on Jun 1, 2024

    @kosuodhmwa
    Author

    closed

  23. kosuodhmwa commented on Jul 28, 2024

    @kosuodhmwa
    Author

    -> easy to bypass with <./bitcoind | grep -v -e 'Socks5'>

  24. added a commit that references this issue on Aug 5, 2024
  25. locked and limited conversation to collaborators on Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions