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

Version

Microsoft Windows [Version 10.0.22621.521]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.15.57.1

Distro Version

Ubuntu 22.04.1 LTS

Other Software

N/A

Repro Steps

Enable systemd via /etc/wsl.conf

Run sudo systemctl list-units --type=service

Expected Behavior

List of services show.

Actual Behavior

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

Diagnostic Logs

No response

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 10
  • Comments: 129

Commits related to this issue

Most upvoted comments

└─(18:13:37)──> cat /etc/wsl.conf                                                                       ──(Sat,Sep24)─┘
[boot]
systemd=true```

Let me unify the answers

  • open a terminal and run this command: wsl --version. If you see “WSL version: 1.0.0.0” (or higher in 1.x.x.x) then you are ready to go. Else, follow the installation instructions until you see it. (Installing KB5020030 might be needed as discussed in https://github.com/microsoft/WSL/issues/9157)
  • now log into WSL by wsl command in the same or new windows console (or ubuntu for example, if you have many distributions)
  • inside the wsl shell, edit /etc/wsl.conf file as root or with sudo: sudo nano /etc/wsl.conf (use your favorite linux editor)
  • insert these 2 lines
[boot]
systemd=true
  • exit the shell
  • shutdown wsl: wsl --shutdown
  • then restart it again: wsl.

EDIT: 2023-03-07 There were new cases and new defining moments to solve the problem. In addition to above lines, as a summary of things below, here are a few new requirements to be aware of:

in addition to /etc/wsl.conf with correct content:

  • we need the new WSL 1.x.x series, or Store version (latest 1.1.3.0, as of now),
  • and version 2 (WSL2 not WSL),
  • and LF/0A line endings (not CRLF/0D0A)
  • also dbus inside the distro might be needed, install related packages so that users can use it too. (at least, Debian comes without dbus)
  • also acpi inside the distro causes problems, uninstall related packages.

Problem solved: Goto https://github.com/microsoft/WSL/releases, download new version of WSL (0.67.6 and higher), install and reboot your system. Enable systemd via /etc/wsl.conf Then retry.

Thanks to @echoechoin.

it is not %userprofile%\.wslconfig you would be editing. it is /etc/wsl.conf inside. you will need to have root access

wsl  # in cmd or powershell
sudo nano /etc/wsl.conf # or use your fav editor
  #insert those 2 lines you have, then save the file and exit the editor
  # Ctrl+X for nano, confirm write, confirm the name
exit
wsl --shutdown #  first shutdown
wsl # then restart

PS: this .wslconfig thing might be something that wsl team have in mind. at least for now, that is the other file you need to edit.

PS: please refer to this post down below for a short intro/warning about terminal editors: https://github.com/microsoft/WSL/issues/8883#issuecomment-1465758773

I’m running a fully updated 21H2 version, was unable to start WSL with systemd enabled. My wsl.conf came with

[boot]
systemd=true

by default, nevertheless, systemd was not available.

I installed “Windows Subsystem for Linux” from the MS Store, like I always did, which is apparently where the issue comes from. Store version of WSL is broken, and it does not even come up in the Store search (it was hidden and I had to google for the URL).

wsl --status reported that I indeed use WSL2, but my WSL kernel version was 5.10.102.1. Apparently, this version does not support systemd and WSLg. wsl --update also reported that my WSL is updated to the last available version, which is not true. Latest WSL kernel at this moment is 5.15, but this kernel is not listed on MS’s own update catalog.

I tried to download latest WSL from the Github releases page, but the installer just crashed.

My solution was to install WSL from dism: dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
After that, reboot and run wsl --update. Now my kernel version is 5.15 and systemd works properly.

Hi, thanks for your resnpose: About the KB version: Device name pc-PC Processor Intel® Core™ i5-4200M CPU @ 2.50GHz 2.50 GHz Installed RAM 8.00 GB Device ID 6BA11125-2FCF-4573-8DA3-266A8ED87C58 Product ID 00330-80000-00000-AA476 System type 64-bit operating system, x64-based processor Pen and touch No pen or touch input is available for this display

tried the x64 version but when it fails, just in case ive tried all versions, and tried with the 21H1 and 22H2 (i was on 21H1 before thinking having systemD was a good idea xD…)

C:\Users\diegu>wsl --list Distribuciones de subsistema de Windows para Linux: Ubuntu-20.04 (predeterminado)

C:\Users\diegu>wsl -d Ubuntu-20.04 diego@pc-PC:/mnt/c/Users/diegu$ sudo nano /etc/wsl.conf [sudo] password for diego: sudo: a password is required diego@pc-PC:/mnt/c/Users/diegu$ sudo cat /etc/wsl.conf [sudo] password for diego: [boot] systemd=true diego@pc-PC:/mnt/c/Users/diegu$

About the wsl or wsl2 version you pointed me in the right direction:

C:\Users\diegu>wsl -l -v NAME STATE VERSION

  • Ubuntu-20.04 Running 1

C:\Users\diegu>wsl --set-version Ubuntu-20.04 2 Para obtener información sobre las diferencias clave con WSL 2, visita https://aka.ms/wsl2

Conversión en curso. Esta operación puede tardar unos minutos. The operation completed successfully.

C:\Users\diegu>wsl -l -v NAME STATE VERSION

  • Ubuntu-20.04 Stopped 2

C:\Users\diegu>

and 👍 tadaaa! diego@pc-PC:/mnt/c/WINDOWS/system32$ systemctl status --no-pager ● pc-PC State: starting Jobs: 5 queued Failed: 1 units Since: Sun 2023-03-05 10:17:53 -03; 26s ago CGroup: / ├─init.scope │ └─1 /sbin/init

thank you very much!!!

@yilmazdurmaz you are correct, I had been mistakenly editing %USERPROFILE%.wslconfig

[boot]
systemd=true

should go into /etc/wsl.conf on the filesystem inside WSL. And now it works ! I really appreciate your help !

your wsl version is 1.1.3.0 which means you already have a compatible version. that KB update possibly fails since you try to use arm64 on x64, or vice versa (you downloaded a wrong version).

Tried with ubuntu 20.04 and upgraded to 22.04 but still didn’t work

each distro is a new virtual machine, and each machine must be configured separately to start with systemd, then must be restarted.

wsl --list -v # need version 2
wsl --set-version distronameyouset 2
wsl -d distronameyouset
sudo nano /etc/wsl.conf # or any editor that uses LF, or 0A, as new line
exit
wsl --terminate distronameyouset # shutdown single
# wsl --shutdown # shutdown all
wsl -d distronameyouset

there is one thing I am not sure about: this might require an x64 machine but you use x86 (32bit). and one more possible thing is, I don’t know if has any relation, is WSL versus WSL2; can’t say if 1.1.3.0 is possible with WSL but worth checking. try the above way first, then check these possibilities.

EDIT: After receiving the next answer, I put the “set-version” step in case someone in the future reads these steps. we need WSL2.

I already have

[boot]
systemd=true

in .wslconfig. And I did run wsl --shutdown to restart.

Although the question was asked for Windows 11, the same error also comes up in Windows 10 installations if some updates are missing. These steps are for W10 users.

  • Install WSL from within Windows Store
  • Install update KB5020030. (I had to download it manually from the Update Catalog)

This “install from Store” might also solve W11 problems. Check that first if this error happens.

About the wsl or wsl2 version you pointed me in the right direction: wsl -l -v Ubuntu-20.04 Running 1 wsl --set-version Ubuntu-20.04 2

nice! I wasn’t sure about that. It is good to know WSL2 is required to get a working SystemD.

@Oluadepe yes, if /etc/wsl.conf is not present already create a new file and add systemd setting to it.

It worked after an update wsl --update, i tried all the above without success

I still had issues with systemctl probably because of the line breaks. I removed the /etc/wsl.conf file and recreated it again with nano inside WSL and it worked.

wsl --update

I’m running a fully updated 21H2 version, was unable to start WSL with systemd enabled. My wsl.conf came with

[boot]
systemd=true

by default, nevertheless, systemd was not available.

I installed “Windows Subsystem for Linux” from the MS Store, like I always did, which is apparently where the issue comes from. Store version of WSL is broken, and it does not even come up in the Store search (it was hidden and I had to google for the URL).

wsl --status reported that I indeed use WSL2, but my WSL kernel version was 5.10.102.1. Apparently, this version does not support systemd and WSLg. wsl --update also reported that my WSL is updated to the last available version, which is not true. Latest WSL kernel at this moment is 5.15, but this kernel is not listed on MS’s own update catalog.

I tried to download latest WSL from the Github releases page, but the installer just crashed.

My solution was to install WSL from dism: dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart After that, reboot and run wsl --update. Now my kernel version is 5.15 and systemd works properly.

I did exactly what you stated here. for some reasons my kernel version still remains at 5.10.102.1

Hi @doraemonxxx, Here, this might be the culprit in your case 😉

dism.exe ... /norestart

Please first restart your PC and then check if the problem continues. Also check if the “default” is to use version 2, not version 1.

https://learn.microsoft.com/en-us/windows/wsl/install#upgrade-version-from-wsl-1-to-wsl-2

Ubuntu 22.04 comes with a config file set for systemd, thus it should work fine if WSL gets installed fine and set correctly.

Installed Windows, WSL2 and Ubuntu this weekend. In ‘/etc/wsl.conf’ it was already set to true, but systemd did not work. Out of frustration I changed it to false, shutdown, change back to true and shutdown again. Now systemd is working 😫

ps. wsl --version returns help…

@dieguiariel Thanks , bro. “wsl --set-version Ubuntu-2204 2” made it. stu**d ms…

On Windows 10, running these commands fixed systemd issue:

sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig

sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target

Found it from this link: https://gist.github.com/alyleite/ca8b10581dbecd722d9dcc35b50d9b2b

Распределение по умолчанию: Ubuntu-20.04 Версия по умолчанию: 2 (WSL-2) Версия ядра: 5.10.102.1

I got an error:

sudo systemctl status postgresql

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

I did all the things above:

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

I did run wsl --shutdown to restart

Yeah so I just figured it out now whenever I run the command and it just takes a while and gives me Failed to list units: Transport endpoint is not connected

@TylerJaacks based on the kernel version you posted, you’re using WSL 0.65.1. In order to use systemd you’ll have to upgrade to latest release, WSL 0.67.6. What is the output of wsl --version or wsl --status?

I was spending an hour trying to get systemd working on an old WSL install of Arch. /etc/wsl.conf was perfectly fine, yet systemd did not start.

For anyone who is convinced that everything else is right: You need a symlink in /sbin (or, well, /usr/bin), which is part of new Arch installs but not my old one: ln -s ../lib/systemd/systemd init

systemd works like a charm now. 😃

@MeechaPooch you seem you have edited the config file to add default user. My guess is that you used an editor that changed the line endings from linux format (LF-0A) to dos format (CRLF-0D0A). system fails to load the config file in this case.

try hexdump /etc/wsl.conf and see if this is the case (does Ubuntu have hexdump by default? you may need to install it)

Fixing it depends on the editors to use and their settings for this format, and it will be long to give instructions here. Please search the internet about fixing this line ending problem. It really works when I change CRLF-0D0A into LF-0A. Thank you so much, I will go crazy without your help.

@MeechaPooch you seem you have edited the config file to add default user. My guess is that you used an editor that changed the line endings from linux format (LF-0A) to dos format (CRLF-0D0A). system fails to load the config file in this case.

try hexdump /etc/wsl.conf and see if this is the case (does Ubuntu have hexdump by default? you may need to install it)

Fixing it depends on the editors to use and their settings for this format, and it will be long to give instructions here. Please search the internet about fixing this line ending problem.

@nathanneibauer looks like your WSL was updated on 2/12/2014, but the kernel version is 5.10.16. That’s an old kernel. Latest WSL kernel is 5.15.146.1.

I just did a quick test and systemd is working right after installation:

Installing: Ubuntu 22.04 LTS
Ubuntu 22.04 LTS has been installed.
Launching Ubuntu 22.04 LTS...
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: elsaco
New password:
Retype new password:
passwd: password updated successfully
The operation completed successfully.
Installation successful!
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.146.1-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage


This message is shown once a day. To disable it please create the
/home/texas/.hushlogin file.
elsaco@texas:~$ cat /etc/wsl.conf

[boot]
systemd=true
elsaco@texas:~$ systemctl status
● eleven
    State: running
     Jobs: 0 queued
   Failed: 0 units
    Since: Mon 2024-02-12 13:56:45 PST; 16s ago
   CGroup: /
---cut---

WSL info:

WSL version: 2.1.1.0
Kernel version: 5.15.146.1-2
WSLg version: 1.0.60
MSRDC version: 1.2.5105
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22631.3085

@yilmazdurmaz @elsaco I have checked the link above, and it turns out that I just need to type “wsl --update” in the command prompt to update to the store version. and it works after that, thank you

I found this thread useful. I was struggling with the upgrade and realised that the WSL2 was installed but I also needed to update existing distros to be of the new version. I found this comment and the following one very useful. https://github.com/microsoft/WSL/issues/8883#issuecomment-1455090207

@dieguiariel Hola, dear Diegu. Your solution worked for me. Muchas gracias🙏

2. sudo nano /etc/wsl.conf Add the following content: [boot] systemd=true

The file doesn’t exist on my Debian system and after creatiing it and following your steps my systemd is still not running in WSL.

Edit: Found the reason. Your formatting is wrong. Should have been:

[boot]
systemd=true

Now it works fine! 😃

@fredxia , using daemonize is just overkill as it is an ancient relic of programs. and at least for Ubuntu and Debian distros, there is no need for such a thing either, let alone if it works as it should for this is not a stand-alone Linux system because, again, it was created in ancient times before Linux even existed. ubuntu change logs for example has “unstable” in each version maintained last 10 years.

However here, there are just a couple of missing things in instructions, and this discussion has them most, if not all to solve problems in modern (and easy) ways. From the command you gave, it seems that system is possibly a Debian and it misses dbus. just installing it would even solve their problem. [here in this answer above from @elsaco ]https://github.com/microsoft/WSL/issues/8883#issuecomment-1458687389) tells libpam-systemd would solve without going fancy.

Alright, it is bugging my mind, so I dug a few more. there are issues posted with a similar error Transport endpoint is not connected and some users say it might be related to acpi which should not be activating for WSL. I have checked #8867 and #9029.

run systemctl list-unit-files | grep acpi and see if you have a service for it. disable systemd if necessary. if so, then there are two possible solutions to try here and here. if systemctl do not work, run apt list --installed |grep acpi and maybe try checking for /usr/lib/systemd/system/acpid.service or any acpid file nearby under systemd folder.

I am not deep into the solving but they basically say to remove it. worth to check. Please share if this is the case and if the issue is solved.

PS: for comparison, my Ubuntu distros (no customization) under W10 21H2 do not have any acpi service, nor acpi installed.

@yilmazdurmaz Thanks alot as described in #9029 removing acpid has worked for me

@yilmazdurmaz that’s correct, Debian distro (at least the one pulled by wsl --install Debian is from the winget store, didn’t try with the msstore version) is lacking dbus package, preventing systemd from working. After adding it systemd status --user is still not working showing Failed to connect to bus because of the missing PAM module. After installing libpam-systemd it works. Without this plugin(s) PAM won’t be able to Register user sessions in systemd control group hierarchy. Use pam-auth-update for more details.

Quick test:

No libpam-systemd package:

elsaco@RIPPER:~$ systemctl status --user
Failed to connect to bus: No such file or directory

libpam-systemd installed:

elsaco@RIPPER:~$ systemctl status --user
● RIPPER
    State: running
     Jobs: 0 queued
   Failed: 0 units
    Since: Tue 2023-03-07 11:00:44 PST; 11s ago
   CGroup: /user.slice/user-1000.slice/user@1000.service
           └─init.scope
             ├─139 /lib/systemd/systemd --user
             └─140 (sd-pam)

Hi @B0ba-Yaga, it seems, in Debian, it might be one of these: either you forgot to create /etc/wsl.conf with the correct content, or you created it with an editor that uses CRLF line endings (we discussed just above). I suggest you check these probabilities. however, for Ubuntu, you somehow disabled systemd for USER.

I already have Ubuntu 20 and 22 with no issue running it. I have now downloaded the current Debian (update note says 11.6) and with the correct config file, it gave me only the error you described for the Ubuntu: Failed to connect to bus: No such file or directory. despite the error, systemd is running and the root user can use it.

I searched for this second error, and it is directly related to DBUS, in fact to its absence. apt list --installed | grep bus will tell you it is missing. I installed dbus for debian, sudo apt-get install dbus, and immediately, the problem is solved 🎉 🎉 🎉 (yours should also be solved, I am hoping)


Fact summary, in addition to /etc/wsl.conf with correct content:

  • we need the new WSL 1.x.x series, or Store version (latest 1.1.3.0, as of now),
  • and version 2 (WSL2 not WSL),
  • and LF/0A line endings (not CRLF/0D0A)
  • also dbus inside the distro so that users can use it too. (at least, Debian comes without dbus)

@yilmazdurmaz thanks for help. its caused by the wsl.conf file encoding or right i dont konw, but i was use explorer.exe to create this file in windows env before. when i drop this file and recreate it in wsl bash, it’s worked now.😊

check this link if you haven’t yet. https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/

Ensuring you are on the right WSL version This change is only available in the “Microsoft Store version of WSL” version 0.67.6 and higher. You can check your version number by running wsl --version. If that command fails then you are running the in-Windows version of WSL and need to upgrade to the Store version

You need to have the “Store version” from now on. Open “Microsoft Store” app and search “Windows Subsystem for Linux”. I forgot where I read but there was a statement like “WSL will continue with the store version and receive all new ‘feature’ updates from there”. and its latest version has the following signature (at least mine shows no update available). Also use wsl --update to make sure of getting fixes. my current version shows these lines.

WSL version: 1.0.3.0
Kernel version: 5.15.79.1

for a few other important details, check my above post: https://github.com/microsoft/WSL/issues/8883#issuecomment-1345472665