Skip to content

WSL Distribution Keep-Alive ​

Many users who are new to WSL2 run into a "puzzle": Linux is installed, so why does it "shut down by itself" shortly after you close the terminal? Why can't it keep running?

This article first describes this behavior, then explains why Microsoft designed WSL this way, and finally shows how to use WSL Dashboard to start a keep-alive Linux distribution.

1. The Current Situation: Linux Shuts Down Automatically Soon After Closing the Terminal ​

Have you experienced the following scenario?

  1. You open the terminal of a Linux distribution, and Linux starts automatically, without needing to run any command;
  2. After closing the terminal window, Linux does not keep running — about 60 seconds later, it is shut down automatically;
  3. You open the terminal again, and Linux starts automatically once more, and so on.

NOTE

WSL2's default "idle timeout" is about 60 seconds: when there are no running processes in the distribution (for example, when you have closed all terminals), the WSL virtual machine shuts down automatically to free up system resources such as memory.

This behavior is the default design of WSL2 — it is neither a malfunction nor an error.

2. Why Did Microsoft Design WSL This Way? ​

2.1 WSL2 Is Essentially a Lightweight Virtual Machine ​

WSL2 runs a complete Linux kernel through a lightweight Hyper-V virtual machine (utility VM). Every running distribution genuinely consumes memory resources. If all distributions stayed resident in the background, a machine running several distributions at once would waste hundreds of MB or even GB of memory, slowing down the overall performance of the machine.

2.2 The Design Philosophy of Allocating Resources on Demand ​

Windows' design philosophy is "allocate resources on demand, release what is not in use":

  • For most users: opening a terminal = needing Linux; closing the terminal = not needing it for the moment;
  • Only a few users need Linux to run 7×24 hours without interruption.

Therefore, WSL adopts a "start on demand, stop when idle" strategy, automatically returning resources such as memory to the system when they are not needed.

2.3 Analogy: Turning Off the Light When Leaving a Room ​

WSL's "automatic shutdown when idle" is like turning off the light when you leave a room: it saves energy and is more efficient. But for people who "need the light to stay on all the time", it is troublesome — and that is exactly where the need for keep-alive comes from.

TIP

If you need Linux to run continuously (for example, deploying services, running scheduled tasks, setting up a development server, etc.), please read the next chapter and use WSL Dashboard to keep your distribution alive.

3. Using WSL Dashboard to Start a Keep-Alive Linux ​

WSL Dashboard provides two simple ways to keep your Linux distribution running.

Method 1: Click the "Start" Button ​

In the "Installed Linux Distributions" list of WSL Dashboard:

  1. Find the distribution you want to keep alive;
  2. Click the "Start" button on that distribution's row.

After clicking, the distribution is immediately woken up and keeps running; as long as you do not stop it manually, it will not be shut down automatically due to idle. This method suits temporary keep-alive scenarios where you need Linux to keep running now.

Method 2: Check "Automatically start this distro when Windows start." ​

In the "Installed Linux Distributions" list of WSL Dashboard:

  1. Click the "Settings" button on the target distribution's row to open the settings dialog;
  2. In the dialog, check "Automatically start this distro when Windows start.";
  3. Save the settings.

After checking, the distribution starts automatically every time Windows starts/logs in, without any manual operation, achieving "keep-alive on boot". This method suits scenarios where Linux needs to stay online for a long time (such as development servers and resident services).

TIP

  • Only needed temporarily → use Method 1 (click "Start");
  • Needs to stay online long-term → use Method 2 (check "Automatically start this distro when Windows start.").