Only one port can be accessed by the host through localhost at the same time
Windows build number: 10.0.19536.1000
Steps to reproduce:
- Listen on port A via
nc -l <PortA>. - The browser accesses
http://localhost:PortA, and the console can output the browser request body. - Listen on port B via
nc -l <PortB>. - When the browser accesses
http://localhost:PortB, the error ERR_CONNECTION_REFUSED directly appears. - Shut down wsl2 through the
wsl.exe --shutdowncommand, repeat the test in the order of 3, 4, 1, 2, and the result is that PortB can receive the packet, and PortA has an error ERR_CONNECTION_REFUSED.
Another reproduction method:
Using vscode's wsl-remote plug-in, it can be started correctly through the code . command for the first time. After closing vscode and using the command to open it again, the file under wsl cannot be displayed and an error message is displayed.
I think I'm running into this issue as well. I've just upgraded to 19536 and can't use vscode and my localhost:3000 app at the same time.
I have exactly the same issue:
- Opening a Remote WSL instance in VSCode (works)
- Run
vue ui localhost:8000gives error ERR_CONNECTION_REFUSED
After wsl --shutdown
- Run
vue ui localhost:8000works- Open a Remote WSL instance in VSCode gives error

Similar issue to previous comments, but slightly different error path.
Windows 10 Pro Insider Preview Build 19536.rs_prerelease.191211-1446 (WSL 2 Enabled)
- Open a Remote WSL instance.
- Start node server on WSL (running in a Docker container for an additional complication 🙂 )
- Cannot access the server at
localhost:3000, which was working prior to Windows update.
Same issue, multiple connections to localhost doesn't work after the update 19536.1000
Issue Identical to @ad-on-is 's comment.
Don't know much about WSL's network arch to debug further.
I have noticed that this is infinitely more flakey than just one port being available.
- I have Docker on my machine setup with WSL2 as its backend. I can run as many containers as I like on Docker and all the ports there get correctly exposed to the host.
- With Ubuntu, however, only the first opened port ever gets exposed to the host, and even that never works if the process dies and then I try to re-bind that port (a good example being VS Code -- if I have to re-open the window, the port won't bind).
- Lastly, with CentOS (which I installed to test a theory about the port issue), I can't bind any ports whatsoever, they all fail.
Not sure what steps I can/should take to debug WSL2 networking, but I can confirm the update to 19536 is what broke me.
Thanks for reporting, there is an issue in Insider Fast, and a fix is coming in a future build (hopefully next week).
I have a LAMP setup on Ubuntu and I have the same issue. I cannot access my sites when using localhost.
Until the fix is coming, I found a workaround. Do a ifconfig and take the inet value of the eth0 connection and use it instead of localhost (for example in your host file).
The only problem is this address changes when the VM restart.
Windows 10.0.19041
Is there a way to downgrade to previous build?
Settings -> Update & Security -> Recovery -> Go back to a previous version of Windows 10
This should allow you to go back to the build you were running prior to this one. Make sure to pause updates from there, else your system will attempt to upgrade again to the problematic build.

I witness that after 19536 update, it started to give me this same error.
I ran into this problem as well. I experimented a little and found out that the problem is better described as "one port per ip address".
For example, I start server A on port 3000 and server B on 4000. If I access server A first on 127.0.01:3000 on the windows side, but I cannot access server B on 127.0.0.1:4000. However, I can access server B using wsl's ip address (let's say 172.23.134.64:4000). If I start another server C on port 5000, I cannot access it from either ip.
So if you are like me, that are only running at most 2 servers in WSL, you are fine for now, and can wait for the update to drop.
@benhillis would you share an update on the fix? Any vague ETA?
Any news on the fix?
Any news on the fix?
Fix was delayed by holiday break but still inbound.
Just installed 19541. Works for me :)
19541 fixed it for me as well. Thanks @benhillis & WSL team!
19541 Seems to have fixed vscode not being able to "fetch remote environment",
However it does NOT seem to have fixed the issue of not being able to access more than one port at a time.
I have a React project which runs on localhost:3000, and a Gatsby project which runs on localhost:8000, previous to this issue, I could run both of them simultaneously and access them from windows on Chrome.
Follow these steps to recreate the behavior:
- Open WSL2
- Go to the React project root directory and run
npm startto start the server running onlocalhost:3000 - On a new tab, go to the root directory of the Gatsby project and run
npm start, this starts the server onlocalhost:8000 - Open Google Chrome and go to
localhost:3000, you should see the react project. - Now try to go to
localhost:8000, you will not be able to see the Gatsby project, and you should see an error like the following:

Fun thing is you can stop both the servers, ONLY start the gatsby project on localhost:8000, and you will get the same error, but if you start another react project, it'll be fine on localhost:3000.
It seems like the first port you use while WSL2 is active sticks and becomes the only one you can see from Windows, running wsl --shutdown on a command prompt window and starting WSL2 again seems to reset the slate, so say now you start the Gatsby project on localhost:8000 first then stop it right away, you won't be able to see any apps running on localhost:3000 if you start them after starting the localhost:8000 app, you will only have port 8000 visible on windows.
@Joe-Pena i observed the same behavior before updating to 19541. :( was feeling hopeful about this version. Does VSCode work while your server is occupying a port? I've had to resort to just using VIM while leaving my react dev server up..
19541 fixed it for me as well. I can able to access port. Thank @benhillis