Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use localhost instead of 0.0.0.0 for local connections #300

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sangaline
Copy link

This addresses the issue in #296. Connecting to 0.0.0.0 only works on Linux, it results in PROXY_TO_PROXY_SOCKET_ERROR on : Error: connect ECONNREFUSED errors on MacOS and Windows. There's some discussion of this in nodejs/node#14900. This PR changes the target host from 0.0.0.0 to localhost in order to make it more cross-platform compatible.

@Apollon77
Copy link
Contributor

Hm ... waaaiiitt ... It's not that easy!

Nodejs 18 changed the order of node.js dns lookups to resolve IPv6 over IPv4. When you change it to localhost then you most likely end up in ipv6 only ... so this change might have other side effects and should be considered carefully.

Right binding to 0.0.0.0 means "bind ipv4 only". I do not know what happens if you bind to localhost ... does that now (nodejs 18+) mean you bind ipv6 only? or some mixture?

@doaortu
Copy link

doaortu commented Aug 20, 2024

what about 127.0.0.1 ? it resolve to localhost and ipv4.
I can't say it will work on windows tho, I don't use windows to do development work.

@hiebra
Copy link

hiebra commented Feb 23, 2025

I see this must be a problem (not a PROBLEM) because the PR was rejected and I'm just now creating a fork to change the code and make it work for the Windows proxied target environment my VS Code extension needs to be deployed in

I'd like to live close to the main branch so I give you an idea. Why not putting 0.0.0.0 by default and allow clients to set a custom value?. That is a no risk solution

I suppose the other occurrences of 0.0.0.0 should be treated the same way (I'm going to do so in my fork). If not, please tell me

Great code. Thank you

NOTE: The commit referenced bellow was to try what @doaortu proposed. It didn't work until I changed it to localhost, the @sangaline's solution

hiebra added a commit to hiebra/node-http-mitm-proxy that referenced this pull request Feb 23, 2025
0.0.0.0 only works on Linux so it's changed by 127.0.0.1 (this fork was born from a rejected PR: joeferner#300)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants