systemctl fails in WSL: system has not been booted with systemd
System 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.
Fix it fast
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=2Match what you see, then jump to its fix
- 1
ps -p 1 prints init (or similar), not systemd.systemd is not enabled in this distributionFix - 2
wsl --version is not recognized, or systemd=true was added and PID 1 is still not systemd.WSL is too old to support systemdFix - 3
wsl -l -v shows VERSION 1 for the distribution.The distribution runs as WSL 1Fix
- 1
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.conf2Fix
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 --shutdown3Verify
Reopen the distribution; PID 1 is now systemd and the service starts.
ps -p 1 -o comm=
sudo systemctl enable --now redis-serverConfirmed by learn.microsoft.com
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 --version2Fix
Update to the current WSL from the Microsoft Store (or wsl --update), then repeat the wsl.conf step.
wsl --update
wsl --shutdown3Verify
wsl --version prints version numbers.
wsl --versionConfirmed by learn.microsoft.com
Cause 3 of 3
The distribution runs as WSL 1
1Check
The systemd setting is only supported on WSL 2.
wsl -l -v2Fix
Convert the distribution to WSL 2, then restart it.
wsl --set-version Ubuntu-24.04 23Verify
The list shows VERSION 2 and PID 1 is systemd.
wsl -l -vConfirmed by learn.microsoft.com
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
Redis warns that vm.overcommit_memory must be enabled
Background saving fails with a fork() error
This is a Linux kernel setting, vm.overcommit_memory, and a container shares the host's kernel.
3 causes, each with a fixServers
systemd fails to start redis-server.service with status=1
redis-server.service: Control process exited, code=exited status=1
Status 1 only says Redis exited at startup.
2 causes, each with a fixServers
systemctl will not start Redis because the unit is masked
Unit redis-server.service is masked
A masked unit is linked to /dev/null, so systemd refuses to start it by any route.
2 causes, each with a fixServers
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 fixServers
Ansible hangs, then times out waiting for the sudo prompt
a playbook using become seems to hang
Ansible ran sudo on the target and never saw the answer it expected.
3 causes, each with a fixServers
Apache on Ubuntu returns 404 Not Found for my site
The requested URL was not found on this server.
On Ubuntu a 404 from Apache usually means the request maps to a path that has no file.
3 causes, each with a fix