73
votes

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

enter image description here

10

10 Answers

44
votes

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.

35
votes

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

wsl --shutdown
30
votes

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.

8
votes

shutdown windows-service Lxss-Manager

6
votes

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

5
votes

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

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.

5
votes

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.

4
votes

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

Get-Service LxssManager | Restart-Service
1
votes

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

1
votes

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.