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

Try all available addresses when connecting to localhost (127.0.0.1 and ::1) #1602

Closed
mcollina opened this issue Aug 16, 2022 · 12 comments
Closed
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mcollina
Copy link
Member

In node v17 (specifically nodejs/node#39987), we switched the default ordering of dns entries to follow what the OS is providing us vs reordering to put IPv4 addresses always first. This creates quite a few issues for folks as some tools only listen to 127.0.0.1 and not ::1.

I think we should try multiple addresses when dealing with localhost when establishing a new connection.

Originaklly reported as #1248.

@mcollina mcollina added enhancement New feature or request good first issue Good for newcomers labels Aug 16, 2022
@kyrylkov
Copy link
Contributor

I don't quite understand what localhost has to do with this issue? In #1248 no localhost was involved.

@mcollina
Copy link
Member Author

This issue is based on this comment: #1248 (comment). There is something we could improve with localhost. As for your problem, we need a repro (feel free to add it to the original issue).

@bnb
Copy link

bnb commented Sep 14, 2022

FWIW I'm getting this when running mockAgent.disableNetConnect() with fetch. Might be a different issue (including an "I'm holding it wrong" issue), but wanted to let y'all know just in case. Here's my monorepo (core is the module that matters here) at the commit that I'm consistently experiencing this issue with.

I think this should work as a way to get the stack traces quickly: git clone https://github.com/cutenode/nodevu && cd nodevu && git checkout 38d46bee90cd0d20762257f9aa6c99ef9ed341ae && npm install && npm run test -w core

@mcollina
Copy link
Member Author

Note: this is better solved in nodejs core. nodejs/node#41625

@jodevsa
Copy link
Contributor

jodevsa commented Nov 26, 2022

Hi @mcollina, seems like this haven't been assigned/implemented yet?

@jodevsa
Copy link
Contributor

jodevsa commented Nov 26, 2022

would this fix nodejs/node#44731 solve this issue?

@mcollina
Copy link
Member Author

Yes, we'd need to enable that setting once it lands.

@KhafraDev
Copy link
Member

Should we enable it by default? Agents should be able to set this option already, under connect in options.

@fawazahmed0
Copy link
Contributor

I faced this issue today in native fetch (v19.5.0) , I had to replace localhost to 127.0.0.1 to fix the issue.

@benwoodward
Copy link

I faced this issue today in native fetch (v19.5.0) , I had to replace localhost to 127.0.0.1 to fix the issue.

this worked for me using native fetch (v18.7.0) inside a .ts file in /lib, thanks!

@xuniorss
Copy link

I faced this issue today in native fetch (v19.5.0) , I had to replace localhost to 127.0.0.1 to fix the issue.

Surprisingly, switching from one to the other worked for me. Thanks.

@Uzlopak
Copy link
Contributor

Uzlopak commented Jan 27, 2024

@mcollina
@KhafraDev
Is this still relevant? autoSelectFamily is already used in undici.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

9 participants