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

🐛 BUG: wrangler dev listens only on ipv4 localhost, not ipv6 #3732

Closed
kentonv opened this issue Dec 26, 2022 · 5 comments · Fixed by #3733 or #4307
Closed

🐛 BUG: wrangler dev listens only on ipv4 localhost, not ipv6 #3732

kentonv opened this issue Dec 26, 2022 · 5 comments · Fixed by #3733 or #4307
Assignees
Labels
bug Something that isn't working quick win Potentially easy/straightforward issue to tackle

Comments

@kentonv
Copy link
Member

kentonv commented Dec 26, 2022

What version of Wrangler are you using?

2.6.2

What operating system are you using?

Linux

Describe the Bug

wrangler dev (with --experimental-local in my case, not sure if that matters) says that it listens on localhost:8787, but when it says this, it is actually listening specifically on 127.0.0.1:8787. On systems that support ipv6, the hostname localhost resolves to two different addresses, ::1 and 127.0.0.1. wrangler dev does not appear to listen on [::1]:8787.

This is usually not a problem, as "correct" programs (e.g. web browsers, curl, or workerd) will try all addresses returned by the DNS query until one of them works. However, Node 18's fetch() function only attempts the first address, throwing an exception if that fails. The first address is always ::1, therefore fetch("localhost:8787") always fails in Node.

Arguably both Node and Wrangler are buggy here. Node should be trying all matching addresses, but Wrangler should also be binding to all matching addresses. Fixing the bug on either side solves the specific problem.

(In my case, I am developing a SvelteKit app with a separate Workers-based backend. Although the SvelteKit app is intended to run on Workers itself, it's easiest to develop using the SvelteKit development workflow on Vite, which uses Node. I wanted it to talk to my local wrangler dev instance and ran into this issue.)

@kentonv kentonv added the bug Something that isn't working label Dec 26, 2022
@JacobMGEvans
Copy link
Contributor

(In my case, I am developing a SvelteKit app with a separate Workers-based backend. Although the SvelteKit app is intended to run on Workers itself, it's easiest to develop using the SvelteKit development workflow on Vite, which uses Node. I wanted it to talk to my local wrangler dev instance and ran into this issue.)

Interesting! Can definitely take a look at this, thanks for the report Kenton 😃

@JacobMGEvans JacobMGEvans self-assigned this Dec 28, 2022
@yoav-lavi
Copy link

yoav-lavi commented May 10, 2023

Hey!

Wanted to add our experience with this:

We have a CLI that (among other functionality) simulates our production generated user API by running a few of our workers locally in miniflare.

We normally start a miniflare at 127.0.0.1:PORT (normally 4000) but we’ve been seeing some issues when people try to use localhost from an IPv6 based application, since localhost translates to ::1 rather than 127.0.0.1.

We'd love to be able to listen on both IPv4 and IPv6 to avoid these cases.

Thanks!

@lrapoport-cf lrapoport-cf added the quick win Potentially easy/straightforward issue to tackle label Jul 7, 2023
@jspspike jspspike self-assigned this Aug 9, 2023
@jspspike
Copy link
Contributor

jspspike commented Aug 9, 2023

This fix for this is in miniflare so I will be transferring the issue there

@jspspike jspspike transferred this issue from cloudflare/workers-sdk Aug 9, 2023
@jspspike jspspike transferred this issue from cloudflare/miniflare Aug 10, 2023
@lrapoport-cf
Copy link
Contributor

reopening because #3733 was reverted with #4014

@lrapoport-cf lrapoport-cf reopened this Sep 28, 2023
@Sammy-T
Copy link

Sammy-T commented Oct 9, 2023

I'm encountering this issue running a local pages environment. Related #2244

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working quick win Potentially easy/straightforward issue to tackle
Projects
None yet
6 participants