vscode-httpyac
vscode-httpyac copied to clipboard
`localhost` seemingly seen as `127.0.0.1`
Hi Andreas... I think I either stumbled upon an issue... or I'm doing something wrong but can't figure out what.
When attempting to reach:
http://localhost:8787/something
The extension's output is:
RequestError: connect ECONNREFUSED 127.0.0.1:8787
Indeed 127.0.0.1:8787
is not a valid connection in my case, but localhost
is. Not sure why this substitution happens. 🤷♂️
FYI I haven't seen any issues with the CLI 🎉.
I have the problem when I want to call a service on the Windows host from the WSL. I think it is an overarching problem of WSL 2. I have not yet found the exact reason when localhost is replaced by 127.0.0.1. I suspect in the NodeJS core after resolution using the local hosts file. The stackoverflow post helped me. Or try https://docs.microsoft.com/en-us/windows/wsl/networking The solutions could also be helpful for using Docker, since presumably WSL2 is also used here.
Hmmm, I'm not using WSL (I'm running VScode on a Mac), and I'm not sure why the CLI would be immune to this vs the vscode extension. Both are using NodeJS (albeit slightly different versions). Neither (I think) is using WSL in my case. 🤷♂️
I also have this issue when using a proxy binded on localhost. Any request gives "RequestError: connect ECONNREFUSED 127.0.0.1:3128" because vscode proxy is set on http://localhost:3128.
Linux (Ubuntu), no WSL obviously, no docker.
@boobin Can you possibly help me to create a setup how I can reproduce the error. I believe that it is not a bug of my code but more a general NodeJS or vscode problem. It could be some DNS.resolve issue like https://github.com/nodejs/node/issues/40702. Or I also got some problems with using vscode and the integrated VSCode Proxy override (change http.proxySupport
from override
to off
)
My issue using localhost as http proxy server seems to be resolved with the current versions of vscode and httpYac.
I am closing the issue as the problem here is a DNS resolve. My extension only takes the standards of the NodeJS environment. It would be possible to implement special logic, but it should not be necessary.