WSL icon indicating copy to clipboard operation
WSL copied to clipboard

WSL2 localhost forwarding doesn't seem to work

Open impguard opened this issue 7 years ago • 207 comments

  • 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!

impguard avatar Nov 02 '19 01:11 impguard

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]

impguard avatar Nov 04 '19 06:11 impguard

recently chrome added a change that forces all traffic to https. Try accessing localhost in firefox or setup ssl in your webserver for localhost.

valeryan avatar Nov 09 '19 05:11 valeryan

@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. :)

craigloewen-msft avatar Nov 15 '19 17:11 craigloewen-msft

Yes, it worked since the latest set of builds. Thanks!

impguard avatar Nov 16 '19 09:11 impguard

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

meatherly avatar Dec 19 '19 16:12 meatherly

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.

meatherly avatar Dec 19 '19 18:12 meatherly

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.

jameslai avatar Dec 20 '19 16:12 jameslai

Updated to OS Build 19536.1000 yesterday, and the localhost binding broke to me too

OctavioBR avatar Dec 20 '19 17:12 OctavioBR

same here - please fix!

xanoinc avatar Dec 20 '19 22:12 xanoinc

Same! Went to bed with a functioning localhost:3000 and woke up without.

TerrorOnMtHyjal avatar Dec 20 '19 23:12 TerrorOnMtHyjal

looks like this is the issue - https://github.com/microsoft/WSL/issues/4769

xanoinc avatar Dec 21 '19 00:12 xanoinc

@seanmetrix - indeed, fix is inbound.

benhillis avatar Dec 21 '19 00:12 benhillis

Please fix this. If Chrome or Firefox runs localhost:3000 successfully, but VS-Code got issues in connectivity. and vice versa.

talalsiddiqui avatar Dec 28 '19 14:12 talalsiddiqui

Seems like this problem is solved on OS build 19041.1

takasoft avatar Dec 29 '19 06:12 takasoft

Right now i have this build. and i am facing issue in this build. This is the latest build so far i guess. image

talalsiddiqui avatar Dec 29 '19 06:12 talalsiddiqui

@talalsiddiqui Try to change your Insider settings to "Release Preview" and do Windows Update. That's what I'm using.

takasoft avatar Dec 29 '19 06:12 takasoft

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

talalsiddiqui avatar Dec 29 '19 06:12 talalsiddiqui

Do you know how i can go back to build 19041.

talalsiddiqui avatar Dec 29 '19 06:12 talalsiddiqui

I am in build 19536 and have to restart WSL 2 via powershell.

localhost URLs will stop working

Earlier builds work.

tony avatar Dec 30 '19 14:12 tony

19041 build. Localhost broken (switched to wsl2 to fix folder rename trouble, but there is another serious thing...)

frct1 avatar Jan 03 '20 05:01 frct1