WSL icon indicating copy to clipboard operation
WSL copied to clipboard

WSL2 loses networking after resume from hibernate

Open jamcpherson-clgx opened this issue 8 months ago • 26 comments

Windows Version

Microsoft Windows [Version 10.0.26100.3194]

WSL Version

2.3.26.0

Are you using WSL 1 or WSL 2?

  • [x] WSL 2
  • [ ] WSL 1

Kernel Version

5.15.167.4-microsoft-standard-WSL2

Distro Version

Ubuntu 24.04

Other Software

Appgate SDP 6.4.1-39256-release Zscaler 4.3.0.188

Repro Steps

I have a Dell Latitude 7450 with an "Intel Core Ultra 7" cpu, 32Gb ram. Due to concerns about mis-interactions on resume with USB3 docking stations, $work has disabled sleep in the bios, leaving only hibernate.

I have noticed that after resume from hibernate my WSL2 vm is unable to make use of any network-related functionality - routing and DNS at a minimum.

The consistent misbehaviour is that I lose the ability to resolve DNS - and I cannot get any ICMP Reply packets when I ping lo or ping loopback0.

Sometimes after resume I can see traffic on the eth? interfaces - including both ICMP Request and Reply - but something is blocking the return path inside the VM for every packet. Other times I cannot see any traffic on the interfaces. I can also see that routes are getting updated but no traffic passes.

I've tried restarting systemd-networkd and systemd-resolved, setting the links down and then up, and even tried manually adding routes. Nothing works to get networking back.

I noticed this morning that running reboot in the VM does not bring the stack back up, I have to use shutdown -h.

Expected Behavior

I expect networking to "just work" after resuming from hibernation

Actual Behavior

WslLogs-2025-03-27_10-05-36.zip

Diagnostic Logs

pcaps.zip

jamcpherson-clgx avatar Mar 27 '25 03:03 jamcpherson-clgx

Failed to parse logs. Unexpected file: eth0-post-resume-restart.pcap The log file doesn't contain any WSL traces. Please make sure that you reproduced the issue while the log collection was running.

Diagnostic information
Multiple log files found, using: https://github.com/user-attachments/files/19478814/pcaps.zip
Found no WSL traces in the logs

github-actions[bot] avatar Mar 27 '25 03:03 github-actions[bot]

@github-actions bot - please re-scan the description

WslLogs-2025-03-27_10-05-36.zip

jamcpherson-clgx avatar Mar 28 '25 06:03 jamcpherson-clgx

Diagnostic information
.wslconfig found
Detected appx version: 2.3.26.0

github-actions[bot] avatar Mar 28 '25 06:03 github-actions[bot]

I am not sure if this is related or a different issue, but I have a somewhat similar issue which I think has started after installing Ubuntu system updates. After resuming my PC from sleep, my WSL2 terminal session works just fine and WSL shell can access internet, but the host Windows shell can no longer invoke wsl.exe:

]  wsl
Catastrophic failure
Error code: Wsl/Service/E_UNEXPECTED

This also breaks VSCode connectivity and requires complete wsl shutdown (wsl --shutdown) and then WSL restart. Attaching the minimal log (collected using the preferred method) of invoking wsl.exe and getting an error.

WslLogs-2025-03-31_23-13-32.zip

alexandroid avatar Apr 01 '25 05:04 alexandroid

@alexandroid I experienced this when I was running MinerU in WSL distro with CUDA. vscode suddenly losed connection with WSL when processing a specific file and I tried to restart the connection (but not the restart of WSL) . After that the windows terminal shows exactly the same log as you. Maybe I could reproduce this problem later, and I would attach a log file at this issue then.

LiPtP0000 avatar Apr 02 '25 02:04 LiPtP0000

I experience the same issue after my system resumes from hibernate and WSL was still running:

Image

I need to run wsl --shutdown and then start a terminal again.

tcostermans avatar Apr 03 '25 07:04 tcostermans

One me too, to this that WSL2 is totally broken after hibernate. Running wsl --shutdown doesn't seem to fix all things related to WSL. Docker desktop seems to keep in borked state, trying to restart/quit it doesn't do anything so to fix the state is just easiest to reboot. Neither the VSCode seems to be able to reconnect or reload. So easiest seems to be just rebooting the whole system :(

@alexandroid What is this WSL restart you talk about after shutdown? At least for me, running shutdown and then having wsl running does not fix things.

bestis avatar Apr 04 '25 07:04 bestis

I have the same issue too. I just got a new laptop. Now everytime wake up, I have to wsl --shutdown and reopen wsl inorder to connect to wsl from vscode or cursor.

auroradanier avatar Apr 13 '25 03:04 auroradanier

++ 1 as this is impacting our developers as well.

lukebehling avatar May 01 '25 16:05 lukebehling

Same here.

Closing all the WSL windows/tabs and restarting it temporarily fixes the issue

Einhorntom avatar May 04 '25 12:05 Einhorntom

+1 this seems to be a regression as I had been running WSL with VScode for months without this issue. Now it seems to happen every time my PC wakes from sleep.

Related issues:

  • https://github.com/microsoft/WSL/issues/9490
  • https://github.com/microsoft/WSL/issues/12810

sirianni avatar May 07 '25 14:05 sirianni

I've been having this problem frequently for months now, and it is a serious impediment. Since the only fix I've found is to restart both WSL and vscode, and vscode not only can't save any unsaved work but won't even let me use the UI to copy/paste, unsaved work is just lost as far as I can tell.

This is seriously affecting the viability of windows + wsl for me as a developer, so I really hope it is fixed soon

usernamenumber avatar May 09 '25 15:05 usernamenumber

I just found out that when the wsl shows Catastrophic failure, then if I type wsl again, it still shows error. But when I open wsl using admin user and type wsl, then it boot up fine. And if I go back to previous user window and type wsl, it works fine too.

Seems there are some user right issues?

auroradanier avatar May 12 '25 14:05 auroradanier

This is also happening to me when I try to open a new terminal ATM (both with admin an non admin user - thanks @auroradanier for the tip).

But I have an active shell session that is working perfectly and the IDE is also partially working. The IDE is able to read/update files but not able to use i.e. git (it shows the same error on the IDE's git sidebar)

jose-cabral avatar May 21 '25 09:05 jose-cabral

+1 it has been making developing on windows a huge pain when every time you sleep the machine WSL needs to be restarted loosing all the sessions.

lukolszewski avatar Jul 09 '25 06:07 lukolszewski

The same is happening to me suddenly. The workaround it was create a new task in the task scheduler to execute the command to kill the wsl service: taskkill /f /im wslservice.exe every time the computer wakes up.

MarcosNeco avatar Jul 22 '25 11:07 MarcosNeco

@MarcosNeco - thanks for the work around

solmon avatar Aug 05 '25 13:08 solmon

Same issue here, no Docker Desktop installed.

marrobi avatar Aug 14 '25 07:08 marrobi

Same issue, on wake from sleep, but I don't think it's every time. I can avoid reboot by rm -rf ~/.vscode-server but then I have to re-install extensions. Restarting docker doesn't help. wsl --shutdown doesn't help either.

djradon avatar Sep 03 '25 10:09 djradon

Same issue described above. Sometimes wsl --shutdown (and restarting vscode) resolves the issue, sometimes it also hangs and I have to reboot.

WhiteSage avatar Sep 10 '25 14:09 WhiteSage

Had this issue for over a month, then realised that I had purchased a new dell dock. I updated the firmware for the dock and this issue has resolved.

lhint avatar Oct 15 '25 10:10 lhint

The same is happening to me suddenly. The workaround it was create a new task in the task scheduler to execute the command to kill the wsl service: taskkill /f /im wslservice.exe every time the computer wakes up.

Yeah it works but the problem that you are killing all you opened windows and clearing all your context. So, I would say that it the reason why this problem is annoyed. I've tried to update my laptop firmware too but it couldn't resolve the problem. I feel pain of everyday reopening all my context. Maybe anybody know how to resolve this regular and annoying problem ?

BlackS52 avatar Oct 20 '25 10:10 BlackS52

Today, for the first time in several months, I was able to reconnect vscode to WSL2 (Debian) after sleep/hibernation. I was also able to start a new instance of windows terminal and connect to WSL2. Previously both of those failed with the above "Catastrophic failure Error code: Wsl/Service/E_UNEXPECTED" error. I cannot definitively identify what changed, or if it's actually fixed, but a windows update might've played a role. I will report back if the issue re-occurs.

tjhowse avatar Nov 05 '25 00:11 tjhowse

Issue still present here, OS info

Windows 11 Pro, Build 22631 (version 10.0.22631)

I think its related to the network connection being lost when the device goes to sleep because the same issue happens when I switch wifi networks

ishevch avatar Nov 05 '25 18:11 ishevch

Whoops, I spoke too soon. The issue re-occurred this morning.

Microsoft Windows [Version 10.0.19045.6456]

I'm clutching at straws, but a factor might be whether the docker daemon is running in WSL when the machine hibernates. I'll run some tests.

tjhowse avatar Nov 05 '25 23:11 tjhowse

I've just disable hibernation, flight is normal. Like a temporary measure

sergeyblackwrk-max avatar Nov 06 '25 06:11 sergeyblackwrk-max