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

Using --host :: with --open results in ERR_ADDRESS_INVALID on Windows (and less-than-ideal behavior on GitHub Codespaces) #4855

Closed
chousheng opened this issue May 9, 2023 · 0 comments · Fixed by #4856

Comments

@chousheng
Copy link
Contributor

Bug report

Currently, using webpack-dev-server with --host :: and --open options results in an ERR_ADDRESS_INVALID error in browsers (Chrome, Edge, etc.) on Windows.

The reason is that we are sending http://[::] to the browser and the IPv6 unspecified address :: is considered an invalid host address on Windows.

Note that on macOS and Linux, :: is automatically mapped to ::1 and 0.0.0.0 is automatically mapped to 127.0.0.1. So we have this problem only on Windows.

Interestingly, although 0.0.0.0 is also considered invalid on Windows, using --host 0.0.0.0 with --open is fine because we are replacing the IPv4 unspecified address 0.0.0.0 with localhost before opening the browser.

So, to fix the problem, we can do the same thing for the IPv6 address: replace :: with localhost when the --open option is used.

Besides, on GitHub Codespaces, if we use localhost, the browser opening event will be intercepted and redirected correctly. If we use ::, the browser will be redirected to the wrong address.

I am working on a PR to fix the problem.

Actual Behavior

When running webpack-dev-server --host :: --open, http:://[::] is sent to the browser.

Expected Behavior

When running webpack-dev-server --host :: --open, http://localhost is sent to the browser.

How Do We Reproduce?

Execute an example with the options --host :: and --open on Windows:

$ cd examples/api/simple
$ webpack-dev-server --host :: --open

Please paste the results of npx webpack-cli info here, and mention other relevant information

System:
OS: Windows 10 10.0.20348
CPU: (1) x64 Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
Memory: 414.89 MB / 1023.61 MB
Binaries:
Node: 20.1.0 - C:\Program Files\nodejs\node.EXE
npm: 9.6.4 - C:\Program Files\nodejs\npm.CMD
Browsers:
Internet Explorer: 11.0.20348.380
Google Chrome: 113.0.5672.93
Microsoft Edge: 113.0.1774.35

Related: #1233

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant