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.
In my demo below, I’m showing 2 methods for restarting WSL distributions –
# (Preferred approach) WSL –Shutdown
# Restart LxssManager Service via PowerShell
Restart WSL with WSL –Shutdown
We need to run a basic wsl command to shut down the distro. First, I’m listing my installed WSL distributions followed by the ‘wsl –shutdown‘ 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 we list our WSL distributions 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 (as per your set default distribution).
Restart LxssManager Service Using PowerShell
We need to Run PowerShell as Administrator (or Windows Terminal) for this.
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 of your WSL distros.
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 I opened above in this post.
Other notes: We are unable to restart from within WSL due to the lack of systemd. There are some open-source projects in the works to enable systemd or even add a GUI to manage local WSL distributions. I hope to explore it at some point in the future.
That’s all for now – have a look at the other WSL Tagged posts here if of interest!
Leave a Reply