WSL2 localhost forwarding doesn't seem to work
-
Your Windows build number: Microsoft Windows [Version 10.0.19008.1000]
-
What you're doing and what's happening:
Running Ubuntu 18.04 with WSL 2 enabled. For example running in Powershell
PS C:\Users> wsl --list --verbose
NAME STATE VERSION
* Ubuntu-18.04 Running 2
Within a terminal for WSL2, I run a simple python HTTP server
❯ python -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
Then, trying to access the server from chrome within windows at localhost:8000. I get a "site could not be reached error"
- What's wrong / what should be happening instead:
I believe it should be working since WSL2 supports forwarding. Unfortunately, I'm not familiar enough with the netstack between windows + WSL2 to diagnose. Let me know if I can provide more info. Thanks!
Interestingly, the opposite has been the case for me. 19013 now works again.
Strange.
On Sun, Nov 3, 2019 at 7:19 AM John Lam [email protected] wrote:
I'm seeing this too. But for me 19008 was working, but 19013 is where I see a regression.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/microsoft/WSL/issues/4636?email_source=notifications&email_token=AAOS3XEUEZSKIBNDA6R3D3TQR3MWRA5CNFSM4JIB6CSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC5VDLA#issuecomment-549147052, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOS3XDMWNJYVDUKNL5UEHLQR3MWRANCNFSM4JIB6CSA .
-- Kevin Wu Software Engineer | Riot Games [email protected] [email protected]
recently chrome added a change that forces all traffic to https. Try accessing localhost in firefox or setup ssl in your webserver for localhost.
@impguard localhost now works for you right?
We also added in some more improvements in build 19018, so if you're still experiencing the issue please upgrade and let us know if that resolves it. :)
Yes, it worked since the latest set of builds. Thanks!
This started happening to me recently. I'm currently running:
Windows 10 Insider Preview 19536.1000 (rs_prerelease)
I don't know why but vscode and wsl2 are having networking problems. When I get one working the other stops. 😢
https://github.com/microsoft/vscode-remote-release/issues/2060
When I run nc -lk 0.0.0.0 3000 | bash I get no activity when I try to connect to it using chrome on the windows side.
Can confirm running on the latest Windows 10 Insider Preview 18536.1000 broke the localhost binding between WSL2 and the host. This was previously working for me before.
To reproduce:
On your WSL2 machine, as @meatherly pointed out:
nc -lk 0.0.0.0 3000
Attempt to access that machine using your favorite browser on your host Windows OS at localhost:3000, you'll see no activity.
Then, determine the WSL2 IP, which will generally be visible using ifconfig and looking for the IP assigned to eth0 (depending on your setup). Using that, go back into your browser at [ipaddress]:3000. You'll see the nc command now reports activity.
It appears the localhost binding between WSL2 and the host OS broke in the most recent release.
Updated to OS Build 19536.1000 yesterday, and the localhost binding broke to me too
same here - please fix!
Same! Went to bed with a functioning localhost:3000 and woke up without.
looks like this is the issue - https://github.com/microsoft/WSL/issues/4769
@seanmetrix - indeed, fix is inbound.
Please fix this. If Chrome or Firefox runs localhost:3000 successfully, but VS-Code got issues in connectivity. and vice versa.
Seems like this problem is solved on OS build 19041.1
Right now i have this build. and i am facing issue in this build. This is the latest build so far i guess.

@talalsiddiqui Try to change your Insider settings to "Release Preview" and do Windows Update. That's what I'm using.
I have set my settings to FAST, plus now i changed to Preview Settings and click updates. there are no updates. plus if i go back from updates to windows insider, it doesn't show me SELECTED SETTINGS. somehow it is not updating my settings to Preview
Do you know how i can go back to build 19041.
I am in build 19536 and have to restart WSL 2 via powershell.
localhost URLs will stop working
Earlier builds work.
19041 build. Localhost broken (switched to wsl2 to fix folder rename trouble, but there is another serious thing...)