nbdd0121 / wsld

WSL Daemon - Stable X11 connection and time synchronisation for WSL2
Apache License 2.0
300 stars 26 forks source link

Failed to listen: Address already in use (os error 98) #21

Open msdsk opened 2 years ago

msdsk commented 2 years ago

When running wsld on wsl2 side I get an eror: Failed to listen: Address already in use (os error 98). I have in my setup wsl-vpnkit and systemd which I believe might be interfering somewhere, preventing the socket from being properly established? My .wsld.toml is now just [x11].

nbdd0121 commented 2 years ago

I really should add more context to error messsages😅

Can you check if /tmp/.X0-lock or /tmp/.X11-unix/X0 exists? If so try delete them and retry. Apparently WSL never clean up /tmp directory.

msdsk commented 2 years ago

It seems have been just that, there was indeed /tmp/.X11-unix/X0. Removing it makes it all work perfectly, thanks! E: Though the problem seems to be persisting after reboots. Seems like I need to clean the temp folder every time.

spacebat commented 1 year ago

This workaround is no longer so easy as /tmp/.X11-unix is mounted read-only to prevent deleting the socket: https://github.com/microsoft/WSL/discussions/9189

mprasil commented 1 year ago

@spacebat I think this might only be issue with systemd=true? Anyway if you're using systemd in your WSL distro, I have created this unit to mount rw tmpfs on top of the ro mount WSL makes:

# /etc/systemd/system/rw-x11.service
# Note: This is workaround to make /tmp/.X11-unix rw for wsld

[Unit]
Description=X11 remount service
After=systemd-tmpfiles-setup.service tmp.mount
ConditionPathExists=/tmp/.X11-unix

[Service]
Type=oneshot
ExecStart=/bin/mount -t tmpfs tmpfs /tmp/.X11-unix

[Install]
WantedBy=multi-user.target

Don't forget to sudo systemctl daemon-reload && sudo systemctl enable --now rw-x11.service to run and enable the service for future boots.

RicardoRdzG commented 9 months ago

this is still happening. Following mprasil it can be fixed but every time the tmp files need to be removed before wsld runs