WSL: Single WSL2 localhost port can't be accessed from Windows side
Environment
Windows build number: 10.0.19041.0
Your Distribution version: Ubuntu 20.04
Whether the issue is on WSL 2 and/or WSL 1: Linux version 4.19.84-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Wed Nov 13 11:44:37 UTC 2019
Steps to reproduce
- Create and start a new
create-react-appapp:
npx create-react-app my-app
cd my-app
npm start
- Try to access it from the browser using the localhost address:
localhost:3000-> The browser can’t connect - Re-start the app by specifying a different port
PORT=3001 npm start-> The browser can connect
Further details
I expect that this is due to specific configuration on my machine, but I don’t know what is wrong. I disabled Windows Firewall and it still doesn’t work. Fast Startup is turned off. Accessing the react app through the ip address + port works as expected. Restarting Windows and WSL 2 (multiple times) did not help.
I assume that this issue is similar to issues #5497 and #5298, but I can access servers that are running on different ports (e.g. 5000, 8080, 3001, etc.).
Any workaround would be appreciated. If possible I would like to not need to get into the insider program again, I am hoping I can stay on the stable 2004 version.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 18
Just in case it happened to someone else and there were no such ports open during in-windows inspection, but inside WSL port was listened: it helped me simply to restart WSL by
wsl --shutdown {name}and starting it then again.Thanks a lot for the help. 👍 🙏
It appears that the IP Helper service was the culprit and after disabling it the port worked again. I assume this did not have anything to do with WSL 2 then, therefore I’m closing the issue.
This solved my issue, thank you
What Ono said. Or from powershell, using TCP port
5040as example, which is the Connected Device Platform ServiceIve tried a bunch of other things, but I had to disable IP Helper service to be able to access my stack on
localhost:4200on windows 11, wsl2. weird that this seems to be the issue, i dont think I had this problem with win 10 or running natively on ubuntu. Seems to the same issue as this fella was having too I wonder if there is some conflict here with the service that needs a more serious look at.Easy enough, and safe enough to disable the service through GUI least source:
servicesapp, by searching forservicesapp in the windows searchIP Helperstartup typetodisabledOpen PowerShell and post the output of:
netsh int ipv4 show excludedportrange protocol=tcpnetsh int ipv4 show dynamicport tcp