42

I Can't restart wsl2, the command wsl --shutdown and any other wsl command hangs forever. Also I found the service LxssManager in stopping status also hangs forever.

How can I restart wsl ?

5 Answers 5

130

It looks like the hang LxssManager service is preventing wsl to restart, I found a way to stop LxssManager and then I was able to restart wsl normally.

First get the PID of svchost.exe running LxssManager, open the cmd as administrator and run:

tasklist /svc /fi "imagename eq svchost.exe" | findstr LxssManager

Grab the returned PID, then run task manager as administrator, in the details tab, search for the svchost.exe containing the PID, right click it and select 'end process tree'.

Now you should be able to restart wsl normally with 'wsl shutdown and wsl.

6
  • 7
    Small improvement to the command: tasklist /svc /fi "imagename eq svchost.exe" | findstr LxssManager
    – Peachyz
    Jul 29, 2022 at 6:46
  • 1
    Thanks, this helped! In Windows 11, you can also find the PID of a service in Task Manager's Services tab. Typing L etc. will take you to services starting with that letter.
    – ps2goat
    Oct 6, 2022 at 16:45
  • omg, thank you! WSL sometimes gets stuck after sleep like this and I hate having to reboot for services that won't respond. You saved the day. Oct 9, 2022 at 18:41
  • 1
    I've been getting this issue a lot lately on Windows 11 when waking the machine after sleep. Thank you for this fix! Nov 16, 2022 at 8:55
  • Although I landed here looking for a solution to the problem of "Docker starting forever", killing LxssManager as described solved my problem in a nice non-destructive way. Thank you.
    – Xenox
    Apr 8 at 17:56
3

I was in the same situation and restarting LxssManager service solved my problem.

Start a command prompt with administrative rights (I am logged with a normal user) and copy and paste in order to run the following commands:

sc.exe queryex LxssManager
sc.exe stop LxssManager
sc.exe start LxssManager
sc.exe queryex LxssManager

P.S. If after the second queryex command LxssManager PID is not different then stop did not succeed and you should try to run the commands after switching user to an administrative one.

P.P.S. If you still cannot stop the service, you should use Task Manager to "End process tree" in Details tab (using the PID displayed by queryex command). Make sure you are signed in (is more powerfull than 'run as') as an administrative user.

2
  • 1
    What if LxssManager is trying to stop but never ending and so stop is not possible? (I am getting crazy) Oct 28, 2022 at 7:05
  • 1
    @StefanoScarpanti I was in that situation (after stop command from command prompt as a normal user, Task manager was displaying stopping). I could not "End process tree" from Task Manager "Run as" administrator. But I succeed to stop the service when I switched user to an administrative one. Of course a reboot will do the same but it takes longer. Oct 28, 2022 at 10:11
3

In PowerShell 7 you can use

Get-CimInstance -ClassName Win32_Service -Filter "Name='LxssManager'"

to find PID of the process. In my case the State of the returned object is Stop Pending. Use the returned PID to kill LxssManager:

Stop-Process -Id $(Get-CimInstance -ClassName Win32_Service -Filter "Name='LxssManager'").ProcessId -Force

This made wsl.exe responsive again on my machine.

1
  • 3
    This looks really helpful but gives me Access is Denied in an Administrative Powershell. May 5 at 17:55
1

If you can't kill / restart the process from neither cmd, powershell and task manager (on administrative account), what worked for me was using this tool https://github.com/winsiderss/systeminformer/releases/tag/v2.39.

In this thread it is explained why this type of processes can be almost unkillable https://github.com/microsoft/WSL/issues/1086.

-1

For wsl2 try:

on CMD with admin access:

taskkill /F /FI "IMAGENAME -eq wsl.exe"
taskkill /F /FI "IMAGENAME -eq wslhost.exe"
taskkill /F /FI "IMAGENAME -eq wslservice.exe"
1
  • 2
    I get ERROR: The search filter cannot be recognized.
    – codeananda
    Apr 6 at 16:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.