-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
http.Server
does not treat localhost
as alias of 127.0.0.1
#47785
Comments
Working as intended. Newer versions of node resolve "localhost" to whatever your OS reports the address is, like ::1. |
My hosts file looks like this
Based on this hosts file, what does |
|
So I got So I think this is an actual bug. If you create the simple server mentioned here: angular/angular-cli#25105 (comment) then ...
Other server implementations bind to both the @bnoordhuis could you please confirm this for me thanks 🙂 |
I can confirm that it's not a bug. Node is doing exactly what it's being told to do: bind to ::1. |
Ok, but this behaviour is inconsistent with other server implementations. Do you agree with this? Therefore, I would say that although it is not a bug in the traditional sense, the fact that it does not behave as most developers would expect makes it a bug. This inconsistency with other server implementations affected me in the way described in my original issue. Here is a brief overview. (1) Angular CLI -> (2) Webpack Dev Server -> (3) http.Server (1) here passes Through this special address, I'm able to access several other servers which have been bound to If you search the internet, just within the Angular community, lots of developers have run into a similar problem and have resorted to using |
Pseudocode for what I'm expecting
--- EDIT --- |
That's what happens. The lookup returned ::1, remember? |
@bnoordhuis did you take a look at my pseudocode? The .NET server implementation (Kestrel) for example has this behavior:
|
can I get a second opinion from another member of the Node JS team please 🙂 |
Sure. I agree with @bnoordhuis |
@cjihrig could you please explain why you think that setting the host to this is how other server implementations work, namely Kestrel |
Node isn't Kestrel, and if I recall correctly, Node doesn't try to bind to multiple addresses - it uses the IP address you provide, or the result of a DNS lookup. |
Ah okay, so it is binding to So I'm guessing the pseudocode code for
I am proposing:
This would bring it inline with developer expectations.
I understand, but having used a few different server implementations, the behavior of |
I just dockerized my app and now 127.0.0.1 works fine. And it doesn't outside of Docker. I think that this will trip more people up in the future. I have no comment about its correctness though. Beyond my expertise level. |
Version
v18.14.0
Platform
Microsoft Windows NT 10.0.22621.0 x64
Subsystem
No response
What steps will reproduce the bug?
Steps to reproduce are in this comment
angular/angular-cli#25105 (comment)
How often does it reproduce? Is there a required condition?
Always. Required condition talked about in linked comment.
What is the expected behavior? Why is that the expected behavior?
No response
What do you see instead?
Server unavailable.
Additional information
No response
The text was updated successfully, but these errors were encountered: