-torcontrol does not resolve a hostname if it is given #22236

issue jrawsthorne opened this issue on June 13, 2021
  1. jrawsthorne commented at 8:09 PM on June 13, 2021: none

    Expected behavior

    -torcontrol should try to resolve a hostname if it is given

    Actual behavior

    The hostname is passed as an ip so the connection fails

    2021-06-13T20:35:54Z tor: Error parsing socket address mynode.local:9051
    2021-06-13T20:35:54Z tor: Initiating connection to Tor control port mynode.local:9051 failed
    

    To reproduce

    Add 127.0.0.1 mynode to /etc/hosts and pass -torcontrol=mynode:9051 as an argument. The connection fails. Try with -torcontrol=127.0.0.1:9051 and it works.

    System information

    Bitcoin Core 0.21.1 from https://bitcoincore.org/bin/bitcoin-core-0.21.1/bitcoin-0.21.1-x86_64-linux-gnu.tar.gz Ubuntu 18.04

  2. jrawsthorne added the label Bug on Jun 13, 2021
  3. ghost commented at 8:22 PM on June 13, 2021: none

    What if you replace 127.0.0.1 mynode with 127.0.0.1 mynode.local in /etc/hosts and pass -torcontrol=mynode.local:9051 as an argument?

  4. jrawsthorne commented at 8:37 PM on June 13, 2021: none

    Still get the same error

    2021-06-13T20:35:54Z tor: Error parsing socket address mynode.local:9051
    2021-06-13T20:35:54Z tor: Initiating connection to Tor control port mynode.local:9051 failed
    
  5. jrawsthorne commented at 8:51 PM on June 13, 2021: none
  6. ghost commented at 11:02 PM on June 13, 2021: none

    It works for -proxy. Looks like it calls Lookup() first to resolve the hostname. For -torcontrol it passes the hostname straight through

    Yes we can try using lookup for torcontrol as well. However I noticed a weird thing: hostname works in Ubuntu but fails in Fedora for proxy.

    proxy=localhost:9050
    

    image

  7. ghost commented at 11:04 PM on June 13, 2021: none

    Maybe I need to remove ::1 from hosts file. Ubuntu has a different hosts file(default)

    image

  8. adriansmares cross-referenced this on Jun 20, 2021 from issue Resolve Tor control plane address by adriansmares
  9. laanwj closed this on Jul 21, 2021

  10. sidhujag referenced this in commit fd10b9caec on Jul 23, 2021
  11. juxeii commented at 7:05 AM on April 7, 2022: none

    I still have this problem in 22.0. Tor runs in a docker container and also bitcoind in a separete container(both bridged). proxy="host.docker.internal:9050" resolves fine to the docker host 192.168.1.11:9050 but torcontrol=host.docker.internal:9051 fails with

    2022-04-07T06:26:53Z torcontrol thread start
    2022-04-07T06:26:53Z tor: Error parsing socket address host.docker.internal:9051
    2022-04-07T06:26:53Z tor: Initiating connection to Tor control port host.docker.internal:9051 failed
    2022-04-07T06:26:53Z torcontrol thread exit
    

    What can I do here when both Tor and bitcoind run in containers?

  12. caheredia commented at 7:26 PM on August 13, 2022: none

    I still have this problem in 22.0. Tor runs in a docker container and also bitcoind in a separete container(both bridged). proxy="host.docker.internal:9050" resolves fine to the docker host 192.168.1.11:9050 but torcontrol=host.docker.internal:9051 fails with

    2022-04-07T06:26:53Z torcontrol thread start
    2022-04-07T06:26:53Z tor: Error parsing socket address host.docker.internal:9051
    2022-04-07T06:26:53Z tor: Initiating connection to Tor control port host.docker.internal:9051 failed
    2022-04-07T06:26:53Z torcontrol thread exit
    

    What can I do here when both Tor and bitcoind run in containers? @juxeii were you able to resolve this? I'm running the same setup as you.

  13. caheredia commented at 7:57 PM on August 13, 2022: none

    @juxeii nevermind. I fixed by assigning static IPs to tor and bitcoind, using this example https://forums.docker.com/t/static-ip-on-docker-containers/110412/3

  14. PastaPastaPasta referenced this in commit 0a9d24fb29 on Apr 17, 2023
  15. UdjinM6 referenced this in commit cdd98f0cbb on Apr 18, 2023
  16. bitcoin locked this on Aug 13, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:54 UTC