Skip to content

Instantly share code, notes, and snippets.

@alyleite
Last active April 15, 2024 06:34
Show Gist options
  • Save alyleite/ca8b10581dbecd722d9dcc35b50d9b2b to your computer and use it in GitHub Desktop.
Save alyleite/ca8b10581dbecd722d9dcc35b50d9b2b to your computer and use it in GitHub Desktop.
Failed to connect to bus: Host is down - WSL 2

» sudo systemctl daemon-reload

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

==============================================

Edit*

  1. Open /etc/wsl.conf with any editor:

sudo nano /etc/wsl.conf

  1. Add the following contents and save them

[boot] systemd=true

  1. Close the Linux window
  2. Execute the following command in PowerShell

wsl --shutdown

wsl

  1. Problem Solving

==============================================

just try:

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

exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME

snap version

@adriben
Copy link

adriben commented Jan 30, 2023

Thank you!

@nssol-wang-ziwen
Copy link

It doesn't work for me. Just when im executing the exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME the Terminal it's closed abruptly. I arrived here trying to see the rclone status with systemctl status rclone

metoo

@joocfresh
Copy link

thank you so meowwwch

@Naga-Prasad2001
Copy link

this works fine with ubuntu kernel

@reed-soul
Copy link

thanks.

@SalehAcehUtara
Copy link

bash: syntax error near unexpected token `<'

@SalehAcehUtara
Copy link

This is how to do it after I followed the method, the information above appears

@premryp
Copy link

premryp commented Mar 12, 2023

Thank you very much!! I tried this, but it doesn't work!! Thank you for wasting my time!!

😁😁😁😁😁

Maybe you don't know to resolve the issue. I tried the same setup and it is working for me. Better destroy your machine.

@galihsangraa
Copy link

THANKS

@eg-fxia
Copy link

eg-fxia commented Mar 27, 2023

Thanks.

@yilmazdurmaz
Copy link

hey all. I have just noticed these commands were for the times systemd was not fully part of the WSL. it is now truly an integrated part of WSL2 (WSL version 1 would still need this)

Also, Debian distros lack dbus and related packages giving extra errors even with perfect installation. in new true WSL2/systemd way, you will need libpam-systemd (or check what else related is missing) in that case.

We have a long discussion about solving mainly this problem, and in my answers there, I try to summarize solutions whenever possible. microsoft/WSL#8883

@jvictornascimento
Copy link

obrigado!

@cppfuns
Copy link

cppfuns commented Apr 2, 2023

Thanks.

@duzhuoshanwai
Copy link

Thanks

@liwsakilive
Copy link

Thanks

@hsedr
Copy link

hsedr commented Apr 26, 2023

Thanks!!!

@hoopan007
Copy link

It worked! Thanks!

@yohanespradono
Copy link

@KhalidMh 's solution above worked for me. thanks!

@arturslab
Copy link

It works, thanks!

@githubsjnsd
Copy link

been looking for a fix to this for months. thanks

@yilmazdurmaz
Copy link

It is Q3 of 2023, and if you still need this trick, then you can be sure you are doing something wrong.

@phunq-0851
Copy link

it still works, thank a lot

@resticDOG
Copy link

Thanks!

@LenaDu
Copy link

LenaDu commented Sep 11, 2023

Worked well. Thanks!

@junfengbj
Copy link

Very impressive. Thanks for sharing!

@Xpom1
Copy link

Xpom1 commented Oct 24, 2023

Thanks!!!

@sbwiecko
Copy link

it worked for me to, just make sure to go the next line after [boot]:

[boot]
systemd=true

@sarahnadi
Copy link

It worked! Thank you

@Jiwangreal
Copy link

Jiwangreal commented Apr 3, 2024

The $LOGNAME meaning is the same as whoami command, assigning a value to $LOGNAME if its not existing

@Faaiq-84
Copy link

it didn't work even with wsl 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment