Skip to content

Setting torcontrol overrides proxy address #25265

Closed

Description

@kroese

When using Bitcoin in combination with Tor, to generate a hidden service to allow for inbound connections, it is needed to add torcontrol like this:

proxy=1.2.3.4:9050
torcontrol=1.2.3.4:29501

The problem is that adding torcontrol results in overriding the proxy address with 127.0.0.1 and the end-result is that Bitcoin cannot connect to Tor any longer:

connect() to 127.0.0.1:9050 failed after wait: Connection refused (111)

It should have connected to 1.2.3.4 instead.

So why does adding torcontrol overrides the configured address for proxy?

Activity

  1. changed the title [-]Setting torcontrol overrides proxy[/-] [+]Setting torcontrol overrides proxy address[/+] on Jun 1, 2022
  2. fjahr commented on Jun 19, 2022

    @fjahr
    Contributor

    @kroese can you share any relevant logs outputs and also what other settings you are using that are networking related?

  3. laanwj commented on Jun 20, 2022

    @laanwj
    Member

    So why does adding torcontrol overrides the configured address for proxy?

    To be precise, it overrides the specific proxy for NET_ONION, e.g. -onion.
    See https://github.com/bitcoin/bitcoin/blob/master/src/torcontrol.cpp#L385

    I guess it shouldn't be doing so if an explicit one was provided on the command line.

  4. fjahr commented on Jun 20, 2022

    @fjahr
    Contributor

    So why does adding torcontrol overrides the configured address for proxy?

    To be precise, it overrides the specific proxy for NET_ONION, e.g. -onion. See https://github.com/bitcoin/bitcoin/blob/master/src/torcontrol.cpp#L385

    I guess it shouldn't be doing so if an explicit one was provided on the command line.

    That's a good hint! I will look into it unless you have already started working on it.

  5. laanwj commented on Jun 21, 2022

    @laanwj
    Member

    No I haven't, feel free to pick it up!

  6. luke-jr commented on Jul 26, 2022

    @luke-jr
    Contributor

    If you want to override -torcontrol, you should be using -onion. Overriding -proxy is expected behaviour (otherwise why use -torcontrol at all?).

  7. fjahr commented on Jul 26, 2022

    @fjahr
    Contributor

    If you want to override -torcontrol, you should be using -onion. Overriding -proxy is expected behaviour (otherwise why use -torcontrol at all?).

    To me, this doesn't make sense. -onion is the more specific version of -proxy, so it makes sense that -onion overrides -proxy. But the interactions with any other parameter should be consistent between the two. Everything else is very confusing.

  8. vasild commented on Aug 18, 2022

    @vasild
    Contributor

    This was briefly discussed in #15423 (comment).
    Related PR: #22830.

    IMO it is ok that the auto-discovered Tor proxy overrides the generic one from -proxy because -proxy could be just an ordinary SOCKS5 proxy unrelated to the Tor network. If that is not ok, then the user has the option to override the auto-discovered one by using -onion. That is,
    -proxy < -torcontrol (auto-discover) < -onion
    looks reasonable to me.

    If it is changed to
    -torcontrol (auto-discover) < -proxy < -onion
    then there is no way for the user to setup a configuration that uses auto-discovery + a manually specified non-Tor-related SOCKS5 proxy (with -proxy). The auto-discovery is nice because it returns a correct location, even after configuration changes in the network or the Tor daemon, without user interaction.

  9. Fidel76y commented on Oct 14, 2024

    @Fidel76y

    According to my understanding bitcoin core designed automatically to configure tor when using torcontrol, when torcontrol is active the device automatically manages the tor instance making it override the manual proxy configuration

  10. vasild commented on Nov 5, 2024

    @vasild
    Contributor

    According to my understanding bitcoin core designed automatically to configure tor when using torcontrol,

    It automatically configures the location of the Tor proxy, used for outgoing connections to Tor. Don't confuse this with the creation of the Tor hidden service for accepting incoming connections from Tor, that is controlled by -listenonion=0|1.

    @kroese, it is a bit unclear from the OP, did it connect to torcontrol and retrieve an invalid proxy from there? That is, 127.0.0.1:9050 instead of 1.2.3.4:9050? That would be odd. I think the torcontrol reports the value of SOCKSPort from torrc and if you are using some tunneling that could probably confuse it. If you know better, you can set the correct value of the Tor proxy with -onion:

    proxy=1.2.3.4:9050
    torcontrol=1.2.3.4:29501
    onion=1.2.3.4:9050
    

    I think that the current priority of -proxy < -torcontrol (auto-discover) < -onion is correct, as elaborated above, so I guess this issue can be closed as "not a bug, will not fix".

  11. kroese commented on Nov 5, 2024

    @kroese
    Author

    @vasild I cannot remember anymore, it was two years ago that I ran into this behaviour. So feel free to close it.

  12. locked and limited conversation to collaborators on Nov 7, 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

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions