Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

systemctl fails in WSL: system has not been booted with systemd

ErrorSystem has not been booted with systemd as init system (PID 1). Can't operate.

Short answer

WSL starts a distribution without systemd unless you turn it on, so systemctl has no init system to talk to. Update WSL, add systemd=true under [boot] in /etc/wsl.conf, then run wsl.exe --shutdown from Windows and reopen the distribution. Or skip systemd and start redis-server directly.

  • Applies to WSL 2 (Store version), Ubuntu 24.04, Redis 7
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check the WSL version from PowerShell, and what runs as PID 1 inside the distribution.

    wsl --version
    # inside the distribution
    ps -p 1 -o comm=
  2. 2Match what you see, then jump to its fix

    1. 1ps -p 1 prints init (or similar), not systemd.systemd is not enabled in this distributionFix
    2. 2wsl --version is not recognized, or systemd=true was added and PID 1 is still not systemd.WSL is too old to support systemdFix
    3. 3wsl -l -v shows VERSION 1 for the distribution.The distribution runs as WSL 1Fix

What does the error look like?

  • System has not been booted with systemd as init system (PID 1). Can't operate.

Cause 1 of 3

systemd is not enabled in this distribution

1Check

systemd is off by default. It is a per-distribution setting in /etc/wsl.conf and works only on WSL 2.

cat /etc/wsl.conf

2Fix

Add the boot section, then restart the WSL virtual machine from PowerShell. Waiting a few seconds after the shutdown lets the setting apply.

# inside the distribution
printf '[boot]\nsystemd=true\n' | sudo tee -a /etc/wsl.conf
# then in PowerShell
wsl.exe --shutdown

3Verify

Reopen the distribution; PID 1 is now systemd and the service starts.

ps -p 1 -o comm=
sudo systemctl enable --now redis-server

Confirmed by learn.microsoft.com

Did this fix it?

Cause 2 of 3

WSL is too old to support systemd

1Check

If wsl --version fails, you are on the older inbox version of WSL, which must be updated first.

wsl --version

2Fix

Update to the current WSL from the Microsoft Store (or wsl --update), then repeat the wsl.conf step.

wsl --update
wsl --shutdown

3Verify

wsl --version prints version numbers.

wsl --version

Confirmed by learn.microsoft.com

Did this fix it?

Cause 3 of 3

The distribution runs as WSL 1

1Check

The systemd setting is only supported on WSL 2.

wsl -l -v

2Fix

Convert the distribution to WSL 2, then restart it.

wsl --set-version Ubuntu-24.04 2

3Verify

The list shows VERSION 2 and PID 1 is systemd.

wsl -l -v

Confirmed by learn.microsoft.com

Did this fix it?

How do I stop it coming back?

  • Enable systemd once per distribution in /etc/wsl.conf and keep WSL updated.
  • For throwaway dev use, start Redis in a terminal with redis-server and skip services.
  • Remember that wsl --shutdown stops every running distribution.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Servers

dnf cannot install MySQL on Amazon Linux 2023

dnf cannot find a mysql-server package on Amazon Linux 2023

Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.