node-http-mitm-proxy icon indicating copy to clipboard operation
node-http-mitm-proxy copied to clipboard

Use localhost instead of 0.0.0.0 for local connections

Open sangaline opened this issue 1 year ago • 3 comments

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.

sangaline avatar Jan 14 '24 15:01 sangaline

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?

Apollon77 avatar Jan 14 '24 16:01 Apollon77

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.

doaortu avatar Aug 20 '24 06:08 doaortu