-
Notifications
You must be signed in to change notification settings - Fork 822
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
Localhost connections from Windows to WSL2 have stopped working (presumed docker desktop related) #5606
Comments
@rib unfortunately this is the case for WSL2 networking. When using WSL, it was an actual subsystem of Windows sharing all the same networking. For WSL2, it is actually running Linux within a VM and thus that VM has its very own IP address and networking. If you want to forward ports from your local machine to the container, you can do so like this: Open an elevated PowerShell or cmd.exe prompt:
Note: it'd probably be wiser to use a different To see what portproxies you already have setup:
|
Thanks for the comment @ctataryn Right, I'm familiar with the general architectural differences between WSL1/2 and can see that it's more fiddly to support routing localhost connections from windows to WSL2 running in a VM but I believe it is intended to be a supported feature of WSL2 (for example please see https://www.bleepingcomputer.com/news/security/wsl2-now-supports-localhost-connections-from-windows-10-apps/) Connecting to localhost has been working fine with WSL2 up until now so it's not a fundamental limitation of WSL2 - I'm saying something has recently regressed on my system. The use of port 80 was only as a bare minimal example. In practice I've been serving http using unpriviledged ports. My current guess is that installing docker desktop had a side effect of deleting whatever bridging/routing tricks were in place beforehand to enable connections to localhost route through to WSL2 - I'm hoping there's some way to fix that. |
Have you tried restarting LxssManager service to see if it starts working again? |
@rib wow, I didn't know that. I always was told WSL2 had completely different networking hence the need to port forward. If that's not the case, I hope they figure out a way to make it work the way it was. It's a pain to have to port forward, and it really was a pleasure in the way it used to work under WSL1 |
@denisdifazio I had rebooted so guess the answer was yes. I found it timed out when I tried explicitly restarting the service which also left things in an inconsistent state (couldn't use wsl2). Since I just rebooted (while I had a pending update) I'm now seeing that WSL2 is working with localhost forwarding working again too - so problem magically solved phew :) Guess maybe the Windows update fixed something. |
Restarting LxssManager solved the issue for me. Thanks @denisdifazio ! How to restart the service: |
Environment
Steps to reproduce
Since it's the only thing remotely non-trivial that I did related to my WSL2 setup, I assume that the issue came from installing docker desktop, from here. I have then uninstalled docker desktop to try and resolve this issue (uninstalling hasn't fixed the issue).
E.g. running netcat from WSL2 like this:
nc -l 80
I can no longer connect to the socket from windows (e.g. from firefox) as
localhost:80
.I can still connect using the IP address for WSL2 found via
ifconfig
though this is less convenient.Expected behavior
Previously I could connect to sockets listening (on 0.0.0.0) within WSL2 from Windows using
localhost
or the IP127.0.0.1
Actual behavior
I can now only connect to WSL2 from Windows using the IP address for WSL2 (e.g. found with
ifconfig
)The text was updated successfully, but these errors were encountered: