WSL: Networking mirrored, WSL2 and the host machine are unable to access each other's services bidirectionally.
Windows Version
Microsoft Windows [版本 10.0.22631.3527]
WSL Version
2.2.4.0
Are you using WSL 1 or WSL 2?
- WSL 2
- WSL 1
Kernel Version
5.15.153.1-microsoft-standard-WSL2
Distro Version
Ubuntu 22.04
Other Software
NONE.
This network issue is not related to Docker. I am using python3 -m http.server 6000 to set up a simple service, and the Python version is 3.10.12.
Repro Steps
Set .wslconfig:
[experimental]
sparseVhd=true
autoMemoryReclaim=gradual
networkingMode=mirrored
dnsTunneling=true
useWindowsDnsCache=true
hostAddressLoopback=true
Turn off the WSL2 firewall.
ufw disable
systemctl stop ufw
Turn off the Hyper-V firewall.
Set-NetFirewallHyperVVMSetting -Name '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -DefaultInboundAction Allow
Set-NetFirewallHyperVVMSetting -Name '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -Enable False
Open port 6000 on the Windows Firewall.
I even tried turning off the entire firewall and restarting the computer.
Run
python3 -m http.server 6000
curl localhost:6000
curl 127.0.0.1:6000
curl 10.0.0.140:6000
/mnt/c/Windows/System32/curl.exe localhost:6000
/mnt/c/Windows/System32/curl.exe 127.0.0.1:6000
/mnt/c/Windows/System32/curl.exe 10.0.0.140:6000
A service is running on the same host machine with port 47990, and WSL2 tries to access this service.
Expected Behavior
curl localhost:6000 #success
curl 127.0.0.1:6000 #success
curl 10.0.0.140:6000 #success
/mnt/c/Windows/System32/curl.exe localhost:6000 #success
/mnt/c/Windows/System32/curl.exe 127.0.0.1:6000 #success
/mnt/c/Windows/System32/curl.exe 10.0.0.140:6000 #success
curl localhost:47990 #success
curl 127.0.0.1:47990 #success
curl 10.0.0.140:47990 #success
/mnt/c/Windows/System32/curl.exe localhost:47990 #success
/mnt/c/Windows/System32/curl.exe 127.0.0.1:47990 #success
/mnt/c/Windows/System32/curl.exe 10.0.0.140:47990 #success
Actual Behavior
curl localhost:6000 #success
curl 127.0.0.1:6000 #success
curl 10.0.0.140:6000 #success
/mnt/c/Windows/System32/curl.exe localhost:6000 #Failed after 21046 ms: Couldn't connect to server
/mnt/c/Windows/System32/curl.exe 127.0.0.1:6000 #Failed after 21046 ms: Couldn't connect to server
/mnt/c/Windows/System32/curl.exe 10.0.0.140:6000 #Failed after 21046 ms: Couldn't connect to server
curl localhost:47990 #Failed after 134050 ms: Couldn't connect to server
curl 127.0.0.1:47990 #Failed after 134050 ms: Couldn't connect to server
curl 10.0.0.140:47990 #Failed after 134050 ms: Couldn't connect to server
/mnt/c/Windows/System32/curl.exe localhost:47990 #success
/mnt/c/Windows/System32/curl.exe 127.0.0.1:47990 #success
/mnt/c/Windows/System32/curl.exe 10.0.0.140:47990 #success
Diagnostic Logs
To be honest, I can’t even determine the IP or other handles of Win11 and WSL2, which renders my network troubleshooting experience useless. I will try to troubleshoot further and send an email later.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 1
- Comments: 29
of course, this is logs WslLogs-2024-06-15_15-30-30.zip
I investigated and found a temporary solution. After turning on the system’s mobile hotspot on Windows, there was no problem with the communication between WSL and the host, and I repeated this solution at the end of collecting the logs.
But I don’t know the specific reason, I hope I can give you some clues
I have the exact same issue. The workaround of turning on the hotspot works for me, but I am curious why is this happening?
Same issue. I have a less resource intensive version of the Wireshark workaround, if anyone is interested:
C:\Windows\System32\conhost.exe --headless powershell.exe -WindowStyle Hidden -Command "& 'C:\Program Files\Wireshark\dumpcap.exe' -i 7 -w NUL --no-promiscuous-mode -f 'igmp'"This is set up to be a scheduled task on startup,
-i 7would need to be changed per system to whatever the loopback interface is (dumpcap.exe -Dto find out), but this is set up to not actually record any packets and to not record anything to a file. This works with or without promiscuous mode, but I have it disabled to eliminate it as a possible factor. Whatever npcap does in this state is what fixes the issue.this may have somthing to do with switching the primary network stack around. the issue started for me when I had to disconnect my cabled eithernet and switch to wifi/hotspot when my interenet was down. When the internet came back up and I changed the network back to wired eithernet I was no longer able to connect from windows to any wsl instance. The really weird part is WSL can still get to the internet, other WSL instances and external systems can still connect to WSL.
networkmode=mirrored local Windows to local Windows: works Remote to local windows: works remote to wsl: works wsl to wsl: works wsl to windows: does not work windows to wsl does not work wsl to remote: works windows to remote: works
both ufw and windows firewall were down.
If I switch WSL to NAT I can get from windows to wsl but remote system can no longer connect to wsl. and wsl can not connect to WSL.
Logs are required for review from WSL team
If this a feature request, please reply with ‘/feature’. If this is a question, reply with ‘/question’. Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.
How to collect WSL logs
Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:
The scipt will output the path of the log file once done.
Once completed please upload the output files to this Github issue.
Click here for more info on logging If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with ‘/emailed-logs’.
View similar issues
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!
Open similar issues:
Closed similar issues:
Logs are required for review from WSL team
If this a feature request, please reply with ‘/feature’. If this is a question, reply with ‘/question’. Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.
How to collect WSL logs
Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:
The scipt will output the path of the log file once done.
Once completed please upload the output files to this Github issue.
Click here for more info on logging If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with ‘/emailed-logs’.
View similar issues
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!
Open similar issues:
Closed similar issues: