You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[WSL2] No network communication between WSL and Windows #4212
* Your Windows build number: Microsoft Windows [Version 10.0.18917.1000] UPDATE: After upgrading to 10.0.18922.1000, I can now access any daemon started from WSL using the VM IP.
Your Windows build number: Microsoft Windows [Version 10.0.18922.1000]
What you're doing and what's happening: I can't communicate with Windows daemons from WSL and vice-versa.
What's wrong / what should be happening instead: Since, WSL2 is a standalone machine, It got its own IP as well as the bridge on Windows. Although I was able to successfully pick the IP of both, I still can't access any daemon started from WSL or Windows from the other side WSL.
This is probably the same as #4192, but since that one is closed with no proper instructions or issue resolution, I'm opening this here.
therealkenc, can I get the reference of the duplicate issue you are referring to when closing this one? I understand you are under huge pressure of endless number of issues, but closing the issue like this doesn't help.
You cited the issue. Yes; since you were unblocked (re: "UPDATE"), and there was not enough information for any actionable, it just got the tag. Whether #4192 it is the "same" or not, fair enough. I've deduped ya. But changing this status to open+question is (perhaps) academic. There were no changes in 18922 that would unblock "network communication" but I could be wrong, natch.
therealkenc, thanks a lot! Appreciate reopening it.
Same wise, fair enough, it could've been some issue on my device that related to me being unable to access WSL[2] services from Windows, that I got over in the same time with the update to 18922. My concern is now accessing Windows services from WSL[2] for many reasons.
Same here, running docker run -d -p 0.0.0.0:8080:8080 nginxdemos/hello in wsl2 build: 18922 and trying to reach localhost:8080 from windows gives timeout.
@AjawadMahmoud if you mean to use cat /etc/resolv.conf | grep nameserver, it always points to 192.168.124.1 and it's not working for me. I could also mentioned doc1 and doc2 as an official documentation, but it's not working for both ways (linux->windows and windows->linux).
For me, Linux to Windows isn't working either, but Windows to Linux is working fine. Could it be a firewall rule no your WSL that is preventing Windows from reaching it, since it's now considered a foreign machine.
So, from the lack of interaction in this direction, can I understand that none else but me is not able to connect to Windows services from WSL2? For instance, I have mongodb and Python web server running in Windows, and I can't access them from WSL2 no matter what IP I use.
Jonathan (@onomatopellan), since you are using python3 I assume you are starting Python server from WSL2 and not Windows, right? This is fine with me, I can access WSL2 from Windows, but I can't access Windows services from WSL2.
What is confusing is that you said:
The only thing I did was open TCP and UDP for windows python on the Windows Firewall.
If this is the case then you are really touching on the problem and all what I need to do is opening the ports in Windows Firewall.
Wow! I knew I've added Python and MongoDB to Windows Firewall rules, but what I didn't do was marking Public networks. And, although I'm on Private network, by simply marking Public I was able to access both without an issue. Thanks for pointing this up Jonathan (@onomatopellan), I wouldn't have made this attempt without your message that confirmed this.
UPDATE:
To anyone coming here in the future looking for the answer, two things:
Accessing WSL2 services from Windows is never an issue as long as you are picking the correct IP via ip addr show eth0 in WSL2.
Accessing Windows services from WSL2 should be fine given:
a. You add Inbound Rule exception for the service you have on Windows on Private, Public networks.
b. Use the correct IP to connect to Windows.
at the end of your ~/.profile for your debian-based distro or ~/.bash_profile for your redhat-based distro. This would give you the env variable $WSL_HOST_IP available in your distro and updated always with the correct IP of your Windows bridge, so you can easily do stuff like:
ping $WSL_HOST_IP
curl $WSL_HOST_IP:8080
Reacted by Jonathan, John Milazzo, Yannick, Michael Solomon, Safi, Kaio Duarte, Vibhutha Kumarage, Christiaan Maks, Tommy Fritz, David Arias Fuentes and 1 more
Rich Turner (@bitcrazed), Are you planning any change to this behaviour? If not I would like to contribute to WSL project with a hack guide to explain the same based on the input from this issue. However, I don't want to start publishing details that you are planning to change its behaviour which might result in some future confusion to some.
Could you confirm whether your team are planning to share ports between WSL2 distros and Windows likewise in WSL1 or this is going to be the behaviour going forward?
planning to share ports between WSL2 distros and Windows likewise in WSL1 or this is going to be the behaviour going forward?
Ben basically answered that in #4199here. Status "hypothetically".
But even if, hypothetically, sharing IP address space (sic) à la WSL1 is in the cards, it will almost certainly be behind some yet-to-be imagined configuration setting. Reason being, separation of the address space is a feature not a bug in many use cases. The new behavior (that you have to access the WSL2 side with its address, and the Win10 side with its address) is detailed here. This is all pretty standard fare for folks used to VBox/VMware/QEMU/Hyper-V. It is just taking some getting used to for folks coming off WSL1. Whatever you pen will very likely remain applicable (and has been applicable since VMs were invented).
Since I'm here: Like your use of interop to set $WSL_HOST_IP. Interesting tid-bit: that would be harder to do with a traditional VM like say QEMU, because the VM client has (to a first order) no idea it is living on a Windows host. [Granted usually in that scenario you've set up local names via DNS and aren't going to futz with IPv4 addresses.]
separation of the address space is a feature not a bug in many use cases
Agree. I'm not saying it's bad. I'm just trying to figure out what's the team approach towards this going forward.
Like your use of interop to set $WSL_HOST_IP
This coming from a WSL team member is a good sign I was right in using such an approach.
Alright, then I'm going to finalise a hack guide I just started working on and would post it as separate issue and would welcome your comment on it as well as any other one interested in it. Hope it becomes some part of WSL eco-system as well.
@AjawadMahmoud we always encourage people to write articles and build ontop of WSL! Like the user cerebrate who implemented systemd in WSL 2 or ibuildthecloud who made instructions on running k3s in WSL 2.
And as stated in our docs we are looking into adding localhost capabilities into WSL 2.
That's great, @mscraigloewen. So, I've prepared some form of a hack guide that involves some risk in using it. I would like to have you and the team review it to see if any of the uses in it can be refactored into more safe and secure and novice-ready:
To make this clear, this is what I'm currently using and it's doing great job helping me using WSL2. So, this is not a question about the validity, rather security review of the instructions mentioned, or even better, a call to include the functionality as built-in into WSL2 (and getting my name as contributor to this great project 😁).
Activity
mahmoudajawad commentedon Jun 22, 2019
therealkenc, can I get the reference of the duplicate issue you are referring to when closing this one? I understand you are under huge pressure of endless number of issues, but closing the issue like this doesn't help.
therealkenc commentedon Jun 22, 2019
You cited the issue. Yes; since you were unblocked (re: "UPDATE"), and there was not enough information for any actionable, it just got the tag. Whether #4192 it is the "same" or not, fair enough. I've deduped ya. But changing this status to open+question is (perhaps) academic. There were no changes in 18922 that would unblock "network communication" but I could be wrong, natch.
mahmoudajawad commentedon Jun 23, 2019
therealkenc, thanks a lot! Appreciate reopening it.
Same wise, fair enough, it could've been some issue on my device that related to me being unable to access WSL[2] services from Windows, that I got over in the same time with the update to
18922. My concern is now accessing Windows services from WSL[2] for many reasons.aamkye commentedon Jun 25, 2019
Same here, running
docker run -d -p 0.0.0.0:8080:8080 nginxdemos/helloin wsl2build: 18922and trying to reachlocalhost:8080from windows gives timeout.mahmoudajawad commentedon Jun 27, 2019
@amadeuszkryze, this won't work. To access your WSL2 daemons follow what is mentioned here: #4192 (comment)
aamkye commentedon Jun 27, 2019
@AjawadMahmoud if you mean to use
cat /etc/resolv.conf | grep nameserver, it always points to192.168.124.1and it's not working for me. I could also mentioned doc1 and doc2 as an official documentation, but it's not working for both ways (linux->windows and windows->linux).mahmoudajawad commentedon Jun 28, 2019
For me, Linux to Windows isn't working either, but Windows to Linux is working fine. Could it be a firewall rule no your WSL that is preventing Windows from reaching it, since it's now considered a foreign machine.
mahmoudajawad commentedon Jul 2, 2019
So, from the lack of interaction in this direction, can I understand that none else but me is not able to connect to Windows services from WSL2? For instance, I have mongodb and Python web server running in Windows, and I can't access them from WSL2 no matter what IP I use.
Any luck with this?
onomatopellan commentedon Jul 2, 2019
@AjawadMahmoud I just tested a python3 http simple server on a VM with 18922 and these are the results:
The only thing I did was open TCP and UDP for windows python on the Windows Firewall.
mahmoudajawad commentedon Jul 2, 2019
Jonathan (@onomatopellan), since you are using
python3I assume you are starting Python server from WSL2 and not Windows, right? This is fine with me, I can access WSL2 from Windows, but I can't access Windows services from WSL2.What is confusing is that you said:
I'll give this a shot and comment on this later.
Thanks for your input.
onomatopellan commentedon Jul 2, 2019
It's python3.exe downloaded from the Windows Store and launched from cmd.
File on Windows Firewall is
mahmoudajawad commentedon Jul 2, 2019
Wow! I knew I've added Python and MongoDB to Windows Firewall rules, but what I didn't do was marking
Publicnetworks. And, although I'm onPrivatenetwork, by simply markingPublicI was able to access both without an issue. Thanks for pointing this up Jonathan (@onomatopellan), I wouldn't have made this attempt without your message that confirmed this.UPDATE:
To anyone coming here in the future looking for the answer, two things:
ip addr show eth0in WSL2.a. You add
Inbound Ruleexception for the service you have on Windows onPrivate, Publicnetworks.b. Use the correct IP to connect to Windows.
As a quick hack, you can add:
at the end of your
~/.profilefor your debian-based distro or~/.bash_profilefor your redhat-based distro. This would give you the env variable$WSL_HOST_IPavailable in your distro and updated always with the correct IP of your Windows bridge, so you can easily do stuff like:mahmoudajawad commentedon Jul 4, 2019
Rich Turner (@bitcrazed), Are you planning any change to this behaviour? If not I would like to contribute to WSL project with a hack guide to explain the same based on the input from this issue. However, I don't want to start publishing details that you are planning to change its behaviour which might result in some future confusion to some.
Could you confirm whether your team are planning to share ports between WSL2 distros and Windows likewise in WSL1 or this is going to be the behaviour going forward?
therealkenc commentedon Jul 4, 2019
Ben basically answered that in #4199 here. Status "hypothetically".
But even if, hypothetically, sharing IP address space (sic) à la WSL1 is in the cards, it will almost certainly be behind some yet-to-be imagined configuration setting. Reason being, separation of the address space is a feature not a bug in many use cases. The new behavior (that you have to access the WSL2 side with its address, and the Win10 side with its address) is detailed here. This is all pretty standard fare for folks used to VBox/VMware/QEMU/Hyper-V. It is just taking some getting used to for folks coming off WSL1. Whatever you pen will very likely remain applicable (and has been applicable since VMs were invented).
Since I'm here: Like your use of interop to set
$WSL_HOST_IP. Interesting tid-bit: that would be harder to do with a traditional VM like say QEMU, because the VM client has (to a first order) no idea it is living on a Windows host. [Granted usually in that scenario you've set up local names via DNS and aren't going to futz with IPv4 addresses.]mahmoudajawad commentedon Jul 4, 2019
Agree. I'm not saying it's bad. I'm just trying to figure out what's the team approach towards this going forward.
This coming from a WSL team member is a good sign I was right in using such an approach.
Alright, then I'm going to finalise a hack guide I just started working on and would post it as separate issue and would welcome your comment on it as well as any other one interested in it. Hope it becomes some part of WSL eco-system as well.
craigloewen-msft commentedon Jul 4, 2019
@AjawadMahmoud we always encourage people to write articles and build ontop of WSL! Like the user cerebrate who implemented systemd in WSL 2 or ibuildthecloud who made instructions on running k3s in WSL 2.
And as stated in our docs we are looking into adding localhost capabilities into WSL 2.
mahmoudajawad commentedon Jul 5, 2019
That's great, @mscraigloewen. So, I've prepared some form of a hack guide that involves some risk in using it. I would like to have you and the team review it to see if any of the uses in it can be refactored into more safe and secure and novice-ready:
https://github.com/AjawadMahmoud/wsl-hacks/blob/master/wsl2-networking.md
To make this clear, this is what I'm currently using and it's doing great job helping me using WSL2. So, this is not a question about the validity, rather security review of the instructions mentioned, or even better, a call to include the functionality as built-in into WSL2 (and getting my name as contributor to this great project 😁).
relipse commentedon Feb 11, 2021
I am running elasticsearch on port 9200 on my Windows side, after opening the firewall, I finally got GET traffic through from my wsl2 ubuntu side using curl http://172.30.224.1:9200 but when I try to use PUT to put an index, it just hangs indefinitely. Anyone know what is going on?