I've setup WSL 2 (Ubuntu) and I installed systemd (and systemd-sysv) there. After that, I ran:

sudo mkdir -p /run/dbus
sudo dbus-daemon --system
sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target

Before installing systemd, I updated ubuntu to the 18.10 (using sudo do-release-upgrade multiple times)

It worked a while but now, it only works as a normal user. As root, I got

Failed to list units: Connection reset by peer

on any systemctl command.

Because of this, I can e.g. vier the status of services but I can't enable/disable the startup of dis service or start/stop them.

I could also replicate it on a clean install:

I installed Debian (WSL2) from the Microsoft Store

I executed the following commands: sudo apt-get update -y sudo apt-get install -y dbus-x11 sudo apt-get install daemonize

Then, I executed wsl --shutdown on the host and run:

sudo mkdir -p /run/dbus
sudo dbus-daemon --system
sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target

After that, I had the same results:



proc-sys-fs-binfmt_misc.automount loaded active running Arbitrary Executable File

sys-devices-LNXSYSTM:00-LNXSYBUS:00-ACPI0004:00-VMBUS:00-fc785225\x2d9131\x2d5661\x2dac0c\x2d3a157c61ae15-net-eth0.device loaded active plugged /sys/devices/LNXSYSTM:00/

sys-devices-LNXSYSTM:00-LNXSYBUS:00-ACPI0004:00-VMBUS:00-fd1d2cbd\x2dce7c\x2d535c\x2d966b\x2deb5f811c95f0-host0-target0:0:0-0:0:0:0-block-sda.device loaded active plugged Virtual_Disk sys-devices-LNXSYSTM:00-LNXSYBUS:00-ACPI0004:00-VMBUS:00-fd1d2cbd\x2dce7c\x2d535c\x2d966b\x2deb5f811c95f0-host0-target0:0:0-0:0:0:1-block-sdb.device loaded active plugged Virtual_Disk

and so on but when I ran

sudo systemctl

I got

Failed to list units: Connection reset by peer

Other example:

$ systemctl status dbus
● dbus.service - D-Bus System Message Bus
   Loaded: loaded (/lib/systemd/system/dbus.service; static; vendor preset: enabled)
   Active: active (running) since Fri 2019-12-13 17:56:36 CET; 13min ago
     Docs: man:dbus-daemon(1)
 Main PID: 110
    Tasks: 1 (limit: 4915)
   Memory: 1.2M
   CGroup: /system.slice/dbus.service
           └─110 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only

Dec 13 17:56:36 Daniellaptop systemd[1]: Started D-Bus System Message Bus.
$ sudo systemctl status dbus
Failed to get properties: Connection reset by peer


Output of ver on my host: Microsoft Windows [Version 10.0.19013.1122]

After that I also installed neofetch on the Debian System(in order to show you):

       _,met$$$$$gg.          dan@Daniellaptop
    ,g$$$$$$$$$$$$$$$P.       ----------------
  ,g$$P"     """Y$$.".        OS: Debian GNU/Linux 10 (buster) on Windows 10 x86_64
 ,$$P'              `$$$.     Kernel: 4.19.79-microsoft-standard
',$$P       ,ggs.     `$$b:   Uptime: 9 mins
`d$$'     ,$P"'   .    $$$    Packages: 226 (dpkg)
 $$P      d$'     ,    $$P    Shell: bash 5.0.3
 $$:      $$.   -    ,d$$'    Terminal: /dev/pts/0
 $$;      Y$b._   _,d$P'      CPU: Intel i7-7500U (4) @ 2.903GHz
 Y$$.    `.`"Y$$$$P"'         Memory: 80MiB / 6868MiB
 `$$b      "-.__

Output of uname -a:

Linux <hostname of the host> 4.19.79-microsoft-standard #1 SMP Mon Oct 14 00:50:46 UTC 2019 x86_64 GNU/Linux


It is the same result if I start the system and run

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


sudo mkdir -p /run/dbus
sudo dbus-daemon --system
  • Do a clean install and try that command. Do you see same error? – Biswapriyo Dec 13 '19 at 6:30
  • I will do it when I can(currently, I am behind a http proxy) – dan1st Dec 13 '19 at 6:33
  • @Biswapriyo I've updated my question. – dan1st Dec 13 '19 at 17:05
  • Debian doesn't work. I've tried it. Don't know why but Ubuntu works. – Biswapriyo Dec 13 '19 at 17:08
  • I've also tried it.(see my edit) Is there a workaround? – dan1st Dec 13 '19 at 17:09

This is possible by installing systemd in another way as described here. At first, you need to install git, clone this repository and run the installer as described in the README.md.

sudo apt update
sudo apt install -y git
git clone https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git
cd ubuntu-wsl2-systemd-script/
bash ubuntu-wsl2-systemd-script.sh

After that, you run wsl --shutdown in cmd and start WSL again.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.