WSL: Can't ping failing in both directions after updating to 10.0.20197.0

Environment

Windows build number: [Environment]:: Win32NT             10.0.20197.0 Microsoft Windows NT 10.0.20197.0
Your Distribution version: Release:        20.04
Whether the issue is on WSL 2 and/or WSL 1: WSL2

Steps to reproduce

In WSL2->Win dir

On WSL2:

cat /etc/resolv.conf (gave 172.31.0.1) then 'ping <reported ip addr>'gave:

PING 172.31.0.1 (172.31.0.1) 56(84) bytes of data. From 172.31.7.186 icmp_seq=1 Destination Host Unreachable From 172.31.7.186 icmp_seq=2 Destination Host Unreachable

strace log attached and reported a number of issues

In Win->WSL2 dir On WSL2 determine ip address using: “ip addr|grep eth0” on my system this gave 172.31.7.186 On PS7: ping <ip address determined in step 1>

I then get

ping 172.31.7.186 Pinging 172.31.7.186 with 32 bytes of data: Request timed out. Request timed out. Request timed out. Request timed out.

I verified that sshd was running

strace_wsl_ubuntu_20.04.log

WSL logs:

Expected behavior

ping should complete normally in both directions

Actual behavior

ping failed in both directions

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 13
  • Comments: 36 (1 by maintainers)

Most upvoted comments

This script was posted a couple days ago, and is the only thing that has worked to fix these issues for me. Anytime my WSL networking stops working, with the latest build, seems to only happen after VPN connection. Run this script, everything works again. I think the piece I was missing when I restarting LxssManager and the NetAdapters, was the Host Name Service (hns). YMMV

#5821 (comment)

@sergeivolodin

The posted workaround works for me and I have created a powershell script to run the three steps:

echo "Restarting WSL Service"
Restart-Service LxssManager
echo "Restarting Host Network Service"
Stop-Service -name "hns"
Start-Service -name "hns"
echo "Restarting Hyper-V adapters"
Get-NetAdapter -IncludeHidden | Where-Object `
    {$_.InterfaceDescription.StartsWith('Hyper-V Virtual Switch Extension Adapter')} `
    | Disable-NetAdapter -Confirm:$False
Get-NetAdapter -IncludeHidden | Where-Object `
    {$_.InterfaceDescription.StartsWith('Hyper-V Virtual Switch Extension Adapter')} `
    | Enable-NetAdapter -Confirm:$False

Disabling/enabling the Hyper-V virtual adapter doesn’t work for me on build 20211. I have to reboot Windows every damn time. 😕

The same problem, wsl network does not work when the system wakes up from sleep.

Yep, thats my exact problem. If I leave the cable connected and boot up. WSL2 is fine. As soon as I switch to a wifi or any other connection it creates the problem. If I boot up the laptop with no ethernet connection and no wireless connection WSL2 is automatically disconnected. Even if I was to add the ethernet connection after boot it will still not work.

Same problem happening consistently to me as well. Dell XPS 15 7590 running latest insider build, if laptop sleeps/hibernates, when it resumes WSL2 cannot access internet whatsoever. Rebooting machine completely (non-sleep) brings connectivity back properly.

I’ve found a disable/enable cycle on every Hyper-V Virtual Switch Extension Adapter in your network stack, restores network connectivity and DNS resolution to WSL 2. YMMV, but see my brief How-To.

  • Looks like it’s a Hyper-V issue. Windows Sandbox and other Hyper-V VMs also cannot access the internet.
  • It happens every time my network environment changed. (Change from wired to wireless network in detail.)
  • It’s still not fixed on Build 20206.

Build 20215 and it still doesn’t work. It has been three weeks (and 3 builds) for me, without DNS resolution. I’ve tried everything in my bag of tricks, and most of the work-arounds in this and four other threads with the same or similar issue. We need some kind of update on this, IMHO.

This bug hits Microsoft’s Biggest Customers the Most

Coincidence: DELL seems to be a common denominator. This may be simply a result of larger corporations using VPNs and obviously use DELL laptops through IT services. WSL2 Network connectivity should not just fail after waking up from PC sleep. Briefly disconnecting WiFi or Ethernet breaks ONLY WSL2 nothing else. All the other applications work after wake up and work after reconnecting the network, NOT WSL2.

It’s September 2023, this bug report was posted over 3 years ago and NOT FIXED. This bug ONLY affects WSL1 and WSL2 and hundreds of similar bug reports per year for 10+ years have been posted ALL WITH NO FIX. The people reading these reports also close them like it is not a bug, yet this bug is costing Microsoft BILLIONS as it affects ALL THE BIGGEST customers! It has also got MUCH WORSE in 2023! Users applying “script” fixes find they still do not work either.
You just have to reboot over and over to get it working.

I notice that I also have to start WSL2:Debian first (which then has no network) then start WSL2:Ubuntu then both get network, if you are lucky. Ping to test, and reboot if no ping.
Also only 1 in 6 reboots work and you can’t take a lunch break or it breaks again and then you have to do 2 to 9 reboots or so! FIREWALL? If it was the firewall then the rejection of the connections would be consistent not random.

Still having same issue. Not fix at all 😦

Confirm, build 20211 has this problem and the Hyper-V enable/disable fix doesn’t work for me either.

I ended up uninstalling Docker and it seemed to help. But the problem persist simply by connecting and switching my active network connection WSL2 disconnects.

After playing trying out some other things, I seem to experience it more often now when I go from wireless to wired connections. At my desk I uses a docking station with ethernet and when I plug it in, WSL2 cannot access the network anymore unless I reboot.

Check your windows defender firewall rules. Your probably getting icmp echo requests blocked due to default behavior on private networks.