-
Notifications
You must be signed in to change notification settings - Fork 835
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
Some localhost ports not being forwarded to WSL2 #5942
Comments
A simple |
Sorry, got bit by markdown gobbling the less/greater than symbols I was using. I think I've fixed it now. I am talking about different ports using http protocol. The server name localhost nor what it should resolve to 127.0.0.1 is being forwarded to WSL2 for some, but not all ports. In my original case, I used the default configuration of create-react-app to instantiate a development web server. I could not access it via the following URIs using a Windows browser:
However, I could access it via this URI:
I could also access it via curl on WSL2 using any of the above URIs. Changing the port my server was listening on to 5000 fixes everything and I can access it from all URIs and requesters listed above. BTW, netstat reports the following:
Which I think means WSL2 should be responding to both localhost:3000 (which it does not) and localhost:5000 (which is does) |
Is there something running on port 3000 on the host? |
There wasn't anything running on the ports in question. This morning, my computer updated to build 19042.541 and the bad behavior is no longer present. No explanation, but I guess it's best to close the issue since it seems to have been something isolated to my machine. |
Environment
Steps to reproduce
I've tried this both using create-react-app and a simple express.js server. Any server with port number <= 3088 can not be accessed via a windows browser at URI localhost:<port>. It results in a "localhost refused to connect" error. I've tried Chrome, Firefox, Brave and Edge. I also tried the Invoke-RestMethod command in PowerShell. However, it will work within WSL2 using curl.
If I change the URI from "localhost:<port>" to "<myIP>:<port>", it works in all cases.
If I change the port to anything > 3088, it works.
I've tried turning off the default Windows firewall, closing docker, rebooting without fast reboot enabled. No change in behavior.
This feels like a port forwarding issue from Windows to WSL2.
WSL logs:
Expected behavior
I'd expect any unused port to be accessible on WSL2. I haven't used create-react-app in a long time, so I'm not sure when this behavior changed.
Actual behavior
The default create-react-app port (3000) is not being forwarded to WSL2. My non-exhaustive testing has bounded the port forwarding problem to port numbers <= 3088.
The text was updated successfully, but these errors were encountered: