WSL Ubuntu hangs, how to restart?

Windows 10Windows Subsystem-for-Linux

Windows 10 Problem Overview


Occasionally WSL hangs on Windows 10. Opening "Ubuntu" bash just hangs. Any way to restart WSL without rebooting Windows ?

enter image description here

Windows 10 Solutions


Solution 1 - Windows 10

I believe the most effective way today for WSL2, in Cmd Prompt / PowerShell:

wsl --shutdown

Solution 2 - Windows 10

To expand on kev's answer, you need to restart the LxssManager service. This can be done by opening Task Manager with CTRL SHIFT ESC, going to the Services tab, finding the LxssManager service, right-clicking and selecting Restart.

Solution 3 - Windows 10

You can shut down Ubuntu by using wslconfig (in Windows Command Prompt or PowerShell):

wslconfig /t Ubuntu

and it will start automatically next time you open a shell.

Solution 4 - Windows 10

Open powershell with admin privileges and type the below command to restart the lxxsManger :

Get-Service LxssManager | Restart-Service

Solution 5 - Windows 10

Assuming your wsl distribution name is Ubuntu.

You can use wsl command in Command Prompt(cmd) to find out distribution names and terminate / shutdown / restart a specific distribution.

Restart in sense that you shutdown your wsl distribution and start it again.

  1. Open cmd.
  2. Use wsl -l or wsl --list to list / show all installed distributions. It'll give you output like this. The (Default) is not part of name, just a marker.
Windows Subsystem for Linux Distributions:
Ubuntu (Default)
Ubuntu-20.04
Ubuntu-18.04
  1. Terminate / shutdown your desired distribution using wsl -t or wsl --terminate like
wsl --terminate Ubuntu

and it will start automatically next time when you open it.

Solution 6 - Windows 10

go to windows setting -> Apps & features -> select ubuntu you installed -> click Advanced options(might need to wait a little bit) -> Terminate

enter image description here

enter image description here

Solution 7 - Windows 10

shutdown windows-service Lxss-Manager

Solution 8 - Windows 10

From the windows command prompt, issue wslconfig /L to see the list of registered distributions.

C:\Users\Manoj>wslconfig /L
Windows Subsystem for Linux Distributions:
Ubuntu-16.04 (Default)

Now issue wslconfig /t with the distribution name obtained from above command.

C:\Users\Manoj>wslconfig /t Ubuntu-16.04

You can then see the Ubuntu instance getting terminated.

manoj@Manoj-Laptop:~$ The Windows Subsystem for Linux instance has terminated.
Press any key to continue...

Hope this helps.

Solution 9 - Windows 10

Try these steps:

  1. From your Start Menu, search for "Turn Windows features on or off"
  2. Uncheck "Windows Subsystem for Linux", save your changes, and reboot your computer
  3. Check "Windows Subsystem for Linux", save your changes, and reboot your computer

Your WSL should be working now.

I can't be given credit for this answer. Please give credit to this person and to the person(s) who had originally shared this information.

Update (8/23/21): As an additional remark, I would recommend disconnecting WSL from VS Code prior to closing VS Code. While it is a tad tedious, from my anecdotal experience I have found that doing this extra step reduces the likelihood of the hanging issue occurring.

Solution 10 - Windows 10

While the other solutions work as well, I like this concise command for Windows PowerShell or cmd:

wsl -t Ubuntu

To see which distributions are installed, you can run wsl -l.

Solution 11 - Windows 10

What worked for me was to start Task Manager with Administrator privileges and enable command line in the Processes column by right clicking on any of the existing column. Then find Service Host in front of which there is empty line. Expand it and see if it contains LxssManager. If it does, then terminate it by right clicking and clicking on end task. Then start the WSL and it will work.

Solution 12 - Windows 10

wsl --shutdown

restart PC,

Important note: Please remember to limit hardware resources usage Solution :

If wsl already installed, in PowerShell as admin :

wsl --shutdown

In main user folder create .configwsl file:

C://Users/<$user$>/.configwsl

add the following:

[wsl2]

memory=2GB

swap=0

Solution 13 - Windows 10

Here is my variation on solving the problem.

  1. After starting WSL it looked like the image in the question. Could not do anything and it never changed even after half an hour. Rebooting did nothing to help.

  2. The answers noting to use Task Manager - Services tab to look at LxssManager lead me in the correct direction but did not resolve the problem.

  3. In further reading the solution is to kill the process.

    a. To get the Process Identifier (PID) from a Windows Command Prompt with administrative rights run > sc queryex LxssManager

C:\WINDOWS\system32>sc queryex LxssManager

SERVICE_NAME: LxssManager
        TYPE               : 30  WIN32
        STATE              : 3  STOP_PENDING
                                (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
        PID                : 7928
        FLAGS              :  

b. Using Task Manager - Details tab find the PID, right click and select End Process Tree.

  1. Now go back and start WSL as normal.

Solution 14 - Windows 10

This is a very common issue for Wsl users. The first and easiest way is to run wsl —-shutdown .If you have multiple Wsl machines, run wsl —-shutdown Ubuntu (Run those commands on Administrative Command prompt or Powershell) Or go to Windows Settings -> Apps and Features -> Ubuntu -> Advanced options and click Terminate like on hereAdvanced Ubuntu settings Wsl Or go to Admin/Normal Command Prompt or Powershell, and type in Wsl You will go to your default Wsl machine. If you want to go to another Wsl machine, you can change the default Wsl machine. To see which is your default Wsl machine, Open an administrator command prompt and type thisenter image description here Change that by typing wsl --setdefault <DistributionName>, or wsl -s <DistributionName> Replace Distribution name by your distribution

Solution 15 - Windows 10

How do I restart the Windows 10 subsystem (WSL) ubuntu?

The WSL subsystem runs based on LxssManager services, so run PowerShell under administrator privileges and stop LxssManager.

LxssManager stop command:

net stop LxssManager

Solution 16 - Windows 10

I have this problem sometimes too. I just press Ctrl+C and it goes back to "normal"

Solution 17 - Windows 10

If you try stopping LxssManager in Services and it simply changes to "Stopping" status and hangs forever (can't restart,stop,pause all greyed out):

I was able to get wsl.exe to respond again without reboot by going to Task Manager as Administrator, showing the "Command line" column, then finding all "svchost.exe" in the list that have empty command line (no arguments, no exe) and just blindly killing them all and hoping for the best.

Then refresh Services, LxssManager then showed up as Stopped. right click Start, and can use wsl.exe again.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRoss IvantsivView Question on Stackoverflow
Solution 1 - Windows 10Dane BaliaView Answer on Stackoverflow
Solution 2 - Windows 10DaveView Answer on Stackoverflow
Solution 3 - Windows 10014View Answer on Stackoverflow
Solution 4 - Windows 10Lakshika PariharView Answer on Stackoverflow
Solution 5 - Windows 10Umair KhanView Answer on Stackoverflow
Solution 6 - Windows 10Zhi YuanView Answer on Stackoverflow
Solution 7 - Windows 10kevView Answer on Stackoverflow
Solution 8 - Windows 10Manoj Kumar GView Answer on Stackoverflow
Solution 9 - Windows 10FriskySagaView Answer on Stackoverflow
Solution 10 - Windows 10TigerwareView Answer on Stackoverflow
Solution 11 - Windows 10HammadView Answer on Stackoverflow
Solution 12 - Windows 10araldhafeeriView Answer on Stackoverflow
Solution 13 - Windows 10Guy CoderView Answer on Stackoverflow
Solution 14 - Windows 10SoundwaveView Answer on Stackoverflow
Solution 15 - Windows 10zhuziyiView Answer on Stackoverflow
Solution 16 - Windows 10Avishai BarnoyView Answer on Stackoverflow
Solution 17 - Windows 10petpoidView Answer on Stackoverflow