"Error: Can't open display: :0" fails to run a simple GUI program correctly
Windows build number:
10.0.22631.0
Your Distribution version:
22.04
Your WSL versions:
WSL version: 2.1.5.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.3593
Steps to reproduce:
- Install the WSL distro using
wsl --install - Install the driver from this website
- Install the
x11-appspackage - Run
xeyes
WSL logs:
pulseaudio.log weston.log stderr.log
WSL dumps:
Expected behavior:
The program should be launched with a graphical window
Actual behavior:
The shell outputs Error: Can't open display: :0
I have same problem..... Cant open gimp.....
I sometimes run into this issue, usually restarting WSL will fix it, sometimes I have to restart multiple times.
I wonder if it is something wrong with the socket. Would be nice to have a workaround that doesn't require restarting WSL or of course if it didn't happen in the first place. I never ran into this a few months ago. It was either triggered by updating WSL or the Linux distribution.
I ran into this just now, following the instructions at: https://github.com/microsoft/wslg/wiki/Diagnosing-%22cannot-open-display%22-type-issues-with-WSLg#x11-display-socket
$ ls -la /tmp/.X11-unix
total 72
drwxrwxrwx 2 root root 60 Jul 17 12:18 .
drwxrwxrwt 1000 root root 69632 Jul 17 23:10 ..
srwxrwxrwx 1 terje 1000 0 Jul 17 12:18 X0
$ sudo rm -r /tmp/.X11-unix
rm: cannot remove '/tmp/.X11-unix/X0': Read-only file system
$ cat /mnt/wslg/versions.txt
WSLg ( x86_64 ): 1.0.61+Branch.main.Sha.54f177d201aecda01347f952e01777c75480fc74
Built at: Tue Apr 2 20:52:28 UTC 2024
Mariner: VERSION="2.0.20240112"
DirectX-Headers:
mesa:
pulseaudio: 6f045ff0dca233a939a2aba815f84d177e294122
FreeRDP: c4030980b29322a9cb2190711a5fadeeeb8b6a33
weston: f227edd681479ec3cb2290a25d84d2d3462aebfa
$ rg 'failed to bind' /mnt/wslg/weston.log
1376:[23:06:22.867] failed to bind to /tmp/.X11-unix/X0: Address already in use
1667:[23:06:23.035] failed to bind to /tmp/.X11-unix/X0: Address already in use
1890:[23:06:23.126] failed to bind to /tmp/.X11-unix/X0: Address already in use
2046:[23:06:23.212] failed to bind to /tmp/.X11-unix/X0: Address already in use
2268:[23:06:23.313] failed to bind to /tmp/.X11-unix/X0: Address already in use
2512:[23:06:23.400] failed to bind to /tmp/.X11-unix/X0: Address already in use
2714:[23:06:23.507] failed to bind to /tmp/.X11-unix/X0: Address already in use
2937:[23:06:23.605] failed to bind to /tmp/.X11-unix/X0: Address already in use
3215:[23:06:23.699] failed to bind to /tmp/.X11-unix/X0: Address already in use
3383:[23:06:23.774] failed to bind to /tmp/.X11-unix/X0: Address already in use
Restarting WSL twice got it working again. The commands show a similar output. Even when it working seems it is not a symlink. But the socket is working and I don't get the Address already in use messages in the weston.log.