How to Restart Windows Subsystem for Linux (WSL)

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
wsl shutdown

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.

wsl ubuntu 20.04

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.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts
Categories
Tags

Always On Availability Groups (AAG) (4) AWS (4) AWS Redshift (6) Database Admin (72) Database Backups & Recovery (14) Database Mirroring (2) Error Messages (5) Failover Cluster Instances (FCI) (1) Git Commands (6) Importing & Exporting Data (2) Linked Servers (3) Linux Administration (2) Logging & Monitoring (1) Microsoft Patching (2) MySQL (4) Postgres (6) PowerShell Scripts (2) SQL Certificates & Encryption (3) SQL Server Agent (5) SQL Server CDC (2) SQL Server Data Types (2) SQL Server Management Studio (SSMS) (16) SQL Server Networking (3) SQL Server on Linux (1) SQL Server Patching (2) SQL Server Performance Tuning (6) SQL Server Processes (SPIDs) (7) SQL Server Replication (2) SQL Server Scripts (13) SQL Server Security (4) SQL Server Storage (10) Windows Admin (21) Windows Authentication (2) Windows Automation (1) Windows Events (2) Windows Firewall (4) Windows Subsystem for Linux (WSL) (18)