If your Windows Subsystem for Linux (WSL) instance encounters errors or you’ve updated the .wslconfig
file (e.g., to modify memory limits), restarting your WSL distributions may be necessary. This guide demonstrates two effective methods for restarting WSL distributions:
> (Preferred Approach) Run the WSL --Shutdown
Command
> (Old Method) Restart LxssManager Service (or your Computer)
This is a guide on how to restart a Windows Subsystem for Linux (WSL) distribution on your local machine.
This might be needed if your WSL instance or app within has thrown an error message, or you are changing the .wslconfig file/memory limits as described in MS Docs.
Run wsl –shutdown Command
It’s a basic WSL command we need to run to shutdown a WSL distro, wsl --shutdown
In the example below I’m also checking the status before and after running this command.
# check wsl distros & status wsl -l -v # shutdown the running wsl host wsl --shutdown # check wsl distros & status wsl -l -v
The shut-down command above immediately terminates all running distributions. When I list the WSL distros again for the second time, we see they are all ‘Stopped’.
To start up your WSL distribution, enter WSL as you would normally.
This’ll be done by re-opening Linux tab in Windows Terminal, or by running ‘wsl‘ to enter a new WSL session.
Restart LxssManager Service, or Restart Your Computer
From what I believe, the wsl –shutdown command was released later, and this LxssManager service restart is the old method. Either way, you’re probably getting what you need in the end, a disruptive stop to WSL.
Run the following command in PowerShell as Admin to restart your local LxssManager service:
# restart LxssManager service Get-Service LxssManager | Restart-Service
The LsxxManager service restart has stopped the Ubuntu-20.04 distro.
If you’ve gone this far, you should be rebooting your computer if you have continued issues with a WSL instance/distro.
Hope this helps, if you do have issues feel free to add a comment below I’d be glad to help if I can.
Leave a Reply