Skip to content

How to Enable systemd in WSL2 — Setup, Use Cases, and Troubleshooting

Audience: Developers using WSL2 who want to use systemctl (basic Linux knowledge required)

Key Points

  • Just 2 lines of config Add a [boot] section to /etc/wsl.conf and restart
  • Docker & service management unlocked Use systemctl enable to auto-start services
  • Startup delays are fixable Mask unnecessary services to speed things up

What "System has not been booted with systemd" Means

Run systemctl status in WSL2, and you'll hit this error:

System has not been booted with systemd as init system (PID 1).
Can't operate.
Failed to connect to bus: Host is down

WSL2 ships with systemd disabled by default. WSL's own init process runs as PID 1, so every systemd-dependent command fails.

The fix is a single config change. Before WSL 0.67.6 (September 2022), third-party tools like genie or Distrod were needed. Now it's officially supported.

Check Your Prerequisites

Before configuring, verify your WSL version:

Run in PowerShell
wsl --version

If this command fails, you're on the legacy "inbox" WSL. Run wsl --update to get the Store version.

RequirementCondition
WSL version0.67.6+ (Store version)
Windows 11Store WSL installed
Windows 1021H1+ with KB5020030
WSL generationWSL 2 (WSL 1 is not supported)

Check which WSL version your distro is running:

Run in PowerShell
wsl -l -v

The VERSION column should show 2.

Enable systemd in 3 Steps

Step 1: Edit wsl.conf

Run inside WSL
sudo nano /etc/wsl.conf

Add the following:

/etc/wsl.conf
[boot]
systemd=true

If the file already has content, append the [boot] section.

Step 2: Restart WSL

Shut down WSL completely from PowerShell:

Run in PowerShell
wsl.exe --shutdown

Then reopen WSL. The config change requires about 8 seconds after shutdown to take effect.

Step 3: Verify

Run inside WSL
systemctl status

If you see State: running, you're good. Check the service list:

systemctl list-unit-files --type=service | head -20

Ubuntu 23.04+ has systemd enabled by default

If you installed the latest Ubuntu via wsl --install, systemd is already active. Other distros like Debian and Kali require manual setup.

What You Can Do After Enabling systemd

With systemd running, WSL2 becomes a much more capable Linux environment.

Manage Docker via systemctl

Run Docker Engine directly in WSL2 — no Docker Desktop needed.

sudo systemctl enable docker.service
sudo systemctl start docker
docker run hello-world

Auto-start Services on WSL Boot

Launch web servers and databases automatically when WSL starts:

sudo systemctl enable nginx
sudo systemctl enable postgresql

Other Use Cases

  • snap: The snapd daemon requires systemd, enabling snap package installs
  • MicroK8s: Run lightweight Kubernetes on WSL2
  • Custom services: Manage your own daemons with Unit files

Troubleshooting

Slow Startup After Enabling systemd

This is the most common issue. WSL may take tens of seconds to start.

Cause: Services like systemd-networkd-wait-online.service are waiting for timeouts.

# Identify the bottleneck
systemd-analyze blame | head -10

# Mask unnecessary services (stronger than disable)
sudo systemctl mask systemd-networkd-wait-online.service
sudo systemctl mask multipathd.socket

Changes take effect after wsl --shutdown and restart.

Still Getting the Error

If systemctl still fails, check these in order:

  1. Typo in wsl.conf: Verify systemd=true spelling and [boot] section name
  2. Didn't restart properly: Run wsl --shutdown (closing the terminal isn't enough)
  3. Running WSL 1: Check wsl -l -v — VERSION must be 2
  4. Legacy WSL: If wsl --version fails, run wsl --update

Summary

  • Add [boot] systemd=true to wsl.conf and restart — that's all it takes
  • Docker, nginx, and other services work with systemctl out of the box
  • Fix startup delays with systemd-analyze blamemask

With systemd enabled, WSL2 becomes nearly equivalent to a native Linux environment. You can replicate your server setup directly in WSL2, minimizing the gap between development and production.