Skip to content

WSL2 distro dies when the PC is sleeping #8763

Open

Description

Version

Microsoft Windows [Version 10.0.22621.382]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.15.57.1

Distro Version

Ubuntu-20.04

Other Software

No response

Repro Steps

The bug is floating. Regularly, but not always, I found all WSL2 apps in the Ubuntu distro have been killed while the PC was asleep. Docker Desktop usually survives. Opened shell windows in the Ubuntu distro exit with an error status.

Expected Behavior

All apps are working when waking from sleep.

Actual Behavior

Sometimes apps are killed.

Diagnostic Logs

How to see logs right when the issue happened, without turning logs on permanently for days?

Activity

  1. tmonczko commented on Sep 14, 2022

    @tmonczko

    Unfortunately I don't have any more specific information to contribute either, but I've also noticed this issue in the last two weeks (have been using WSL2 for two years to date).

    Sometimes on waking up Windows from sleep, all WSL tabs in Windows Terminal are still open, but WSL has stopped and all tabs are frozen. To get things going again, I have to run wsl --shutdown from PS, then wsl to start it up again. I'll keep a close eye on it to try to get some more details!

    This is a separate issue from the linux clock going out of sync when Windows goes to sleep.

  2. speller commented on Nov 7, 2022

    @speller
    Author

    As a non-guaranteed workaround, I've disabled automatic Microsoft Store updates. I suppose they were a reason at least for some of the dies. Since that, I've updated Windows to the latest cumulative update and for a couple of weeks, I don't face this issue.

    @argo-wayneb dies during the daytime work can be related to microsoft/wslg#678

  3. tmonczko commented on Nov 9, 2022

    @tmonczko

    I updated Windows (11 Pro) to Version 10.0.22621 (i.e. version 22H2) (Build 22621) a few days ago and it seems to have fixed the problem for me. Interested to hear if it works for others.

  4. thecharlesjenkins commented on Dec 6, 2022

    @thecharlesjenkins

    I have been having this problem since I updated to "2022-11 Cumulative Update for Windows 11 Version 22H2 for x64-based Systems (KB5020044)" 3 days ago. WSL (and all applications using WSL) crash after my computer wakes from sleep and requires a full reboot.

  5. BenjaVR commented on Feb 20, 2023

    @BenjaVR

    I face this issue almost every morning with my laptop running the latest stable Windows 11. On my desktop (latest insiders builds) I do not have this issue however...

    This command (elevated PS prompt) fixes it for me: taskkill /f /im wslservice.exe. Usually I have to restart apps using WSL as well (Docker, JetBrains IDEs ...).

  6. VOID07 commented on Mar 11, 2023

    @VOID07

    I've been facing this issue, too, more frequently after upgrading to W11,
    It requires restarting the whole pc as it does not work trying to kill the service or the process, WSL just freezes.
    When trying to stop the service, it returned 1053 the service did not respond to the start or control request in a timely fashion

    This also happens overnight or whenever the PC sleeps for more than 30 minutes or so.

    I've just downgraded to WSL 1 in hopes it removes the issue, I will let you know if it does.

  7. QAnders commented on Mar 23, 2023

    @QAnders

    This started happening to me too last few days and now seems to happen after every night (or longer time away from the laptop). Running on a Dell XPS 17 with Win 11 21H2 22000.1696, WSL2 Ubuntu 22.04.2.

    I am using Windows Terminal, have a few tabs open and everything is fine. I leave my laptop so that it sleeps or hibernate it and when logging back in the Terminal window has closed.
    VSCode has also lost all connection to QSL and "hangs".

    If I open it it just hangs and no prompt comes up. Any wsl command in PS just hangs, the only solution is to restart the laptop (which is extremally annoying as I have a few databases and Docker containers to spin up again before I can resume work...)

    Same as Charles Jenkins (@thecharlesjenkins), I have two 2022-11 Cumulative Update for Windows 11 (KB5023698 and KB5022836) and the timing is about right for when this started...

    EDIT: I wonder if it has some connection to Docker... If I don't have Docker running it seems as if it is not happening, and I also got a "crash" when starting a few new containers and I got [process exited with code 1 (0x00000001)] in all open tabs as the containers started up...

  8. Seosaidh commented on Mar 24, 2023

    @Seosaidh

    You can add me to the list of people with this same problem. It started a few weeks ago. While building a Linux application via WSL/Visual Studio, it will randomly hang and I have to reboot, as any powershell wsl commands just hang forever.
    Back in February (or maybe earlier) it was working just fine.

    This will happen to me multiple times per day.

  9. QAnders commented on Mar 24, 2023

    @QAnders

    This has gotten completely out of hand!

    It now terminates WSL2 several times a day, also killing Docker desktop and VSCode.
    Trying to restart things completely freezes the processes and only a restart will sort it.

    Previously this happened after sleep or hibernate, but now it happens in the middle of working with the laptop.

  10. VOID07 commented on Mar 25, 2023

    @VOID07

    I've been facing this issue, too, more frequently after upgrading to W11, It requires restarting the whole pc as it does not work trying to kill the service or the process, WSL just freezes. When trying to stop the service, it returned 1053 the service did not respond to the start or control request in a timely fashion

    This also happens overnight or whenever the PC sleeps for more than 30 minutes or so.

    I've just downgraded to WSL 1 in hopes it removes the issue, I will let you know if it does.

    After downgrading to WSL 1, at least it shows the prompt when logging back. I might need to restart the service, but it does not hang.

  11. 2pl commented on Jul 9, 2023

    @2pl

    I have been facing a similar issue for a couple of weeks now.
    Most likely linked to a windows patch as i didn't change wsl version for w while:

    wsl --version
    WSL version: 1.2.5.0
    Kernel version: 5.15.90.1
    WSLg version: 1.0.51
    MSRDC version: 1.2.3770
    Direct3D version: 1.608.2-61064218
    DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
    Windows version: 10.0.19045.3086
    
    

    I usually have two instances of ubuntu 22.04 running, one using wsl1, the other wsl2.
    After resuming from sleep wsl2 hangs, with vmmem process using all available CPU,
    wsl shutdown or teminate hangs.
    wsl1 instance is still ok, but have to reboot to get rid of vmmem process.

  12. 2pl commented on Jul 9, 2023

    @2pl

    seems to be a duplicate of #6982

  13. deragon commented on Nov 27, 2023

    @deragon

    In my case, all the GUI applications running under WSLg die. However, the initial terminal from which they have been launch still runs. It might not be related with this issue and I should probably open a new issue.

    Still, only a few weeks ago, GUI applications survived Sleep mode.

    $ wsl.exe --version
    WSL version: 2.0.9.0
    Kernel version: 5.15.133.1-1
    WSLg version: 1.0.59
    MSRDC version: 1.2.4677
    Direct3D version: 1.611.1-81528511
    DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
    Windows version: 10.0.19045.3693
    
  14. 45 remaining items

  15. enBonnet commented on Dec 3, 2025

    @enBonnet

    Mine hibernating and restarting once per week is working fine as well

  16. a-bj-q commented on Dec 3, 2025

    @a-bj-q

    I've bottomed out my issues on Windoze I think.
    It needed perusing of the "Event Log" and that revealed somewhat cryptic messages about running out of memory.
    Since then I maxed my laptop out at 64GB, and WSL has now been stable, alongside everything else I need to run. Seems it doesn't like being paged in and out.

  17. sboresch commented on Dec 4, 2025

    @sboresch

    [I just wonder how one manages to avoid suspending/hibernating on a laptop ..]

    By necessity, I occasionally suspend(*), and I hibernate at least twice per day. All goes well for several days, even up to two weeks. But at some point, wsl inevitably locks down hard; I had one instance when even taskkill was not enough (wsl after restart was still unusable). Once this happens, it seems as if the next crash is much more to occur quickly (but this is of course completely subjective).

    (*) where I can select, I prefer hibernation over suspend

    The 'out of memory' (or I'd guess some 'race condition' for memory) nevertheless makes sense. All in all, by now wsl feels almost as 'stable' as on my older x86_64 laptop, which has more RAM.

    Unfortunately, I have no (little) Windows skill, so I don't even know how to monitor/search the 'Event log' in a meaningful way. On (pure) Linux, where I in charge of > 50 machines, I know "enough" so that if I can't resolve a bug myself, I can at least provide a useful and detailed bug report. So if any of the WSL developers/maintainers reads this, if you tell me what to watch for / try on the Windows side, I am glad to help.

  18. shivanshthapliyal commented on Dec 5, 2025

    @shivanshthapliyal

    Happening with me too. I haven't found any reliable solution yet. Although a simple restart fixes it for me:

    wsl -d Ubuntu --shutdown
    wsl -d Ubuntu

    But it's just a hassle. I created a silent desktop shortcut that restarts WSL Ubuntu on wake/login. Save this as a .vbs file and double-click it (or add it to Task Scheduler on wake events to run automatically after sleep):

    ' Silent WSL Ubuntu Restart Script (Standalone)
    ' Restarts Ubuntu WSL without showing any windows
    
    Set objShell = CreateObject("WScript.Shell")
    
    ' Shutdown Ubuntu WSL silently
    objShell.Run "wsl -d Ubuntu --shutdown", 0, True
    
    ' Wait 3 seconds for shutdown to complete
    WScript.Sleep 3000
    
    ' Start Ubuntu WSL silently
    objShell.Run "wsl -d Ubuntu -e exit", 0, True
    
    ' Optional: Show a brief notification when complete
    objShell.Popup "Ubuntu WSL restarted successfully!", 2, "WSL Restart", 64

    Not ideal ofcourse, but at least I don't see errors on my IDEs now. Hoping this is fixed soon.

  19. calilafollett-rm commented on Feb 10, 2026

    @calilafollett-rm

    This has recently started happening to me on my work laptop. I'll leave VSCode with a remote WSL session open when shutting down for the day. VSCode is then unable to connect to the remote Ubuntu instance when waking the laptop up the following morning. It just happened again.

    My only recourse has been to issue a shutdown, which seems to hang for a bit before the command finally commits.

  20. bpacholek commented on Mar 10, 2026

    @bpacholek

    Experiencing same behavior as Cali LaFollett (@calilafollett-rm). After sleep often WSL2 is dead, VS Code remote debugging disconnected. Turning it off with wsl --shutdown takes some time and after turning it back on VS Code needs to be also restarted to reconnect. Especially annoying when using Github Copilot in VS Code as then it forces you to cancel the chat and often loses context.

    Asus Z13, Windows 11 25H2 (26200.7922), all OEM drivers, nothing special on the system apart from WSL2, Docker and basic development tools mostly in WSL2.

  21. acadjsr commented on Mar 10, 2026

    @acadjsr

    I was experiencing this on WSL2 on Windows 11 on ARM (X Elite) as well. See my writing up.
    I switched my laptop to x86 where I have more RAM and there I run Linux (legacy CentOS 8) in VirtualBox.
    I experienced this same issue on sleep there too. So it is not WSL2 issue only.
    But I was able to configure Linux Cento 8 so it does not crash in VirtualBox when host laptop returns from sleep.
    If you are interested I may write here what I did.

  22. bpacholek commented on Mar 13, 2026

    @bpacholek

    Dear Microsoft,
    just wanted to share that current state is unbearable and breaks any positive experience related to WSL2. I am currently switching my projects to running natively on Windows with Powershell as a terminal as WSL2 is more than annoying with this issue. Next step will be getting out of Windows completely...

  23. acadjsr commented on Mar 13, 2026

    @acadjsr

    This is not a Windows (WSL2) issue. It is because of Linux. I experience the same with Windows host and Linux guest in VirtualBox.

  24. calilafollett-rm commented on Mar 13, 2026

    @calilafollett-rm

    acadjsr It's still technically a Windows issue though. Probably in the virtualization underpinnings and power management. Regardless, Bartosz Pachołek (@bpacholek) has a point, I do not have these issues on my personal MacBook. Unfortunately, I need to use a Windows laptop for work.

  25. acadjsr commented on Mar 13, 2026

    @acadjsr

    So you use Linux as a guest Virtual machine in your MacBook host, because that would be apple to apple comparison of you not having these issues on your personal MacBook.

    And I fixed this issue by configuring Linux in VirtualBox so now works with sleep.

  26. bartekb commented on Mar 14, 2026

    @bartekb

    acadjsr what did you do to avoid this problem on VBox? Thanks!

  27. acadjsr commented on Mar 14, 2026

    @acadjsr

    Bartek Bubacz (@bartekb)
    Yes.
    I did this for my CentOS 8 VM in VirtualBox in x86-64 laptop.
    This is from my documentation I took when I set this.

    I haven't tried this in WSL2 but it should be possible to do this (or alternative for your Linux - you can search for).

    1. Adjust RCU Stall and Heartbeat (Guest Side)
    Because you are virtualized, the "CPU Stall" you see is often just the guest OS waiting for the VirtualBox hypervisor to give it cycles after a long pause.
    Add these to your /etc/sysctl.conf to make the kernel more "patient" with the hypervisor

    vi /etc/sysctl.conf
    kernel.watchdog_thresh = 60
    kernel.softlockup_panic = 0

    Apply with: sysctl -p

    2. Adjust the Time Synchronization Threshold
    This is done while VM (named "CentOS 8 64-bit") was shut down, in command prompt:

    cd "C:\Program Files\Oracle\VirtualBox"
    VBoxManage guestproperty set "CentOS 8 64-bit" "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold" 5000

    5000 is 5 sec

    3. GRUB changes
    vi /etc/default/grub
    add:
    rcupdate.rcu_cpu_stall_suppress=1 nowatchdog

    to the GRUB_CMDLINE_LINUX line.

    grub2-mkconfig -o /boot/grub2/grub.cfg

    4. To prevent errors after sleep: systemd[1]: systemd-logind.service: Watchdog timeout (limit 3min)!
    mkdir -p /etc/systemd/system/systemd-logind.service.d/
    mkdir -p /etc/systemd/system/systemd-udevd.service.d/
    mkdir -p /etc/systemd/system/systemd-journald.service.d/

    vi /etc/systemd/system/systemd-logind.service.d/watchdog.conf
    vi /etc/systemd/system/systemd-udevd.service.d/disable-watchdog.conf
    vi /etc/systemd/system/systemd-journald.service.d/disable-watchdog.conf

    Add these lines:

    [Service]
    WatchdogSec=0

    Apply the change:

    restart VM.

    5. (An alternative for above) If you see other services (like systemd-journald) also timing out, you can adjust the global hardware watchdog settings in the main system configuration.
    Edit the system config:
    vi /etc/systemd/system.conf
    find and set
    RuntimeWatchdogSec=0
    RebootWatchdogSec=0
    ShutdownWatchdogSec=0

    systemctl daemon-reexec

  28. asiby commented on Sep 23, 2026

    @asiby

    FYI, this has been happening to me every single day since last week.

  29. acadjsr commented on Sep 23, 2026

    @acadjsr

    FYI, this has been happening to me every single day since last week.

    Is it x86-64 or Arm64?
    If it is Arm64 is it Snapdragon X1 or Snapdragon X2 or something else?
    I run this under Arm64 Snapdragon X2 and it never dies after sleep. I have a custom WSL2 set up for this. I can share it if you are interested.
    I also have Arm64 Snapdragon X1 but I was not able to set it up there as with X2. It dies eventually. So there are some differences between X1 and X2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions