-
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
[WSL2] share localhost with Windows #4199
Comments
This one is fundamentally dupe #4106, but we need a landing zone for the request to share localhost in WSL2 à la WSL1. For the time being (if or until that changes) this is by-design. As a rider, not only does WSL not share the IP address space, the address assigned to the container is not stable to the Distribution (like Forest Gump, you never know what IP address you're gonna get). This is exceedingly problematic for numerous common dev scenarios. It would be better if: (a) The nonroutable (usually Note that the current practice of serving up the same Windows |
|
@transtone - Makes sense. May be prudent to change the WSL2 hostname until (hypothetically) we can share IP address with the host. |
Clarification because it was assumed obvious, and maybe wasn't. When I said "whole edifice" I am talking about |
Same issue here. I was following this WSL2 + Kubernetes tutorial: the |
Having the same issue as @scarolan, things work if I shutdown wsl and then start it back up again. |
Same here, but with |
Once updated to build 2004, my wsl remote development experience has been a nightmare. I've been experiencing the issue on 3/3 different machines. SSH connection to the vm, through
As I said, I had the chance to do in depth test on three different pc, all of them showed the same behavior. Sometimes more often, sometimes less. This was the only setup that made cross platform development feasible to setup. There still are a lot of ongoing issues, but they have all been closed some time in the past: #4208 #5298 #4636 #4150 I'm aware Microsoft recommends WSL1 for cross development, due to filesystem performance issues. WSL1 is quite cool, tech wise, but it's not a vm, so there's no guarantee of everything behaving correctly. Like Unix domain sockets. |
I got accessing localhost from Windows 2004 working through deinstalling Docker Desktop and its WSL2 integration. It worked for a few days. |
I changed the insider programme updates to the beta channel and now it's all working again. Not sure what update is messing with this. I'm on: Version 10.0.19042 Build 19042 if that helps anyone. |
The problem seems to be the 2004 update. After that, remote development was completely unreliable for me. Unfortunately i can't roll back to 19042, since the update was more than 10 days ago. |
That is good to know. I'll pause my updates and consider myself lucky. Let's hope this gets resolved quickly. |
I found a solution, at least for the localhost accessability issue. To access localhost from a windows browser, you have to forward the wanted ports via a powershell script, as stated here: |
Since I haven't been able to find a simple solution of kubectl port-foward, I tricked wsl2 with a docker container inside of my distro. docker run --rm --name kubectl --user root -v ~/.kube/config:/.kube/config -p 8080:8080 bitnami/kubectl:latest /
port-forward --address 0.0.0.0 --namespace containerNameSpace containerName 8080:7111 To simplify even more this command can be wrapped into a simple bash script named /usr/bin/kubectl_wsl that can forward all the kubectl commands to the docker container. Create the following bash script at #!/usr/bin/bash
kubectl version
docker run --rm --name kubectl --user root -v ~/.kube/config:/.kube/config -p 8080:8080 bitnami/kubectl:latest "$@" now we can simply run the command as kubectl_wsl port-forward --address 0.0.0.0 --namespace containerNameSpace containerName 8080:7111 I hope this can help someone. |
For us installing chrome on wsl2 was a viable solution (but for this you need a running xserver / xserver setup). The second solution was: localhostForwarding=true |
same issue |
On Windows 20H2 & Ubuntu 20.04 in WSL2, I just solved this issue with running |
This worked for me:
Example: |
Your Windows build number:
C:\Users\XXXX>ver
Microsoft Windows [版本 10.0.18922.1000]
What you're doing and what's happening:
[XXX@XXX ~]$ netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:52742 localhost:x11 ESTABLISHED
tcp 0 0 localhost:52702 localhost:x11 ESTABLISHED
tcp 0 0 localhost:52784 localhost:x11 ESTABLISHED
tcp 0 0 localhost:52700 localhost:x11 ESTABLISHED
tcp 0 0 localhost:52780 localhost:x11 ESTABLISHED
[ed, KC... some snips]
Host don't share loopback with WSL guest (At least now). Reserve DNS takes host's ip as localhost may be confusing
172.17.58.195 is the ip address of the guest. 172.17.58.193 is the ip address of the host.
The problem occurs on every program using reserve dns.
The text was updated successfully, but these errors were encountered: