wslg: wslg: Can't open display: :0 + X11 server is not running

Environment

Windows build number: Microsoft Windows [Version 10.0.22000.282]
Your Distribution version: Ubuntu 20.04
Your WSLg version: 1.0.26

Steps to reproduce

Problem 1: Can’t open display: :0

  1. Update WSL2 (through wsl --update in windows terminal) and before that make sure “Virtual Machine Platform”, “Windows Hypervisor Platform” and “Windows Subsystem for Linux” are turned on in Windows Features.
  2. Install Intel GPU driver for WSL (Note: CsProcessors: {Intel® Celeron® N4000 CPU @ 1.10GHz}, Integrated GPU: {Intel® UHD Graphics 600} and no dedicated gpu)
  3. Run sudo apt update && sudo apt upgrade in wsl terminal
  4. Install x11-apps
  5. Run xcalc or xeyes in windows terminal through wsl xeyes. (Note: when I run xeyes on wsl terminal, it just hangs for a long time and not show up any app)

Result: Error: Can’t open display: :0

Problem 2: X11-server is not running

  1. Run ls /tmp/.X11-unix

Result: show no results, and thus suspect X11-server not running.

WSL logs:

  • Attach WSLg logs from /mnt/wslg You can access the wslg logs using explorer at: \\wsl$\<Distro-Name>\mnt\wslg (e.g.: \\wsl$\Ubuntu-20.04\mnt\wslg)

  • pulseaudio.log pulseaudio.log

  • weston.log weston.log

  • versions.txt versions.txt

Other logs info:

tys@DESKTOP-SDACRC6:/$ echo $DISPLAY
172.26.48.1:0.0

tys@DESKTOP-SDACRC6:~$ ls -la /tmp/.X11-unix
lrwxrwxrwx 1 tys tys 19 Nov  5 10:26 /tmp/.X11-unix -> /mnt/wslg/.X11-unix

tys@DESKTOP-SDACRC6:/mnt/c/Users/tys$ ls -la /tmp/.X11-unix/
total 0
drwxrwxrwx 2 root root  60 Nov  5 10:29 .
drwxrwxrwt 6 root root 260 Nov  5 10:13 ..
lrwxrwxrwx 1 tys  tys   19 Nov  5 10:29 .X11-unix -> /mnt/wslg/.X11-unix

Expected behavior

GUI running without need of other third-party X11-servers such as Vcxsrv.

Actual behavior

Error: Can’t open display: :0. Still needs Vcxsrv to open linux gui apps.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 3
  • Comments: 25

Most upvoted comments

Not sure if it helps anyone, but I had similar issue where wayland application (e.g. gedit) works but X11 application (e.g. xclock/xcalc/firefox/gimp) does not work.

It turns out that if you used your Linux distro before with VcXserv, even after uninstall it, it left something in your Linux distro’s /tmp/.X11-unix folder. The trick is to simply remove this folder, and create a symbolic link to /mnt/wslg/.X11-unix, and everything work now for me.

sudo ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix

@myusrn

(if docker desktop is running, close that first)

sudo umount /tmp/.X11-unix
sudo rm -rf /tmp/.X11-unix
sudo ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix

then open windows command prompt and restart WSL I did wsl --shutdown then restarted wsl by re-opening my wsl client

Hello @tys203831. It looks like your DISPLAY environment variable is incorrectly set… it should be set to :0 and not 172.26.48.1:0.0, probably a remnant of Vcxsrv uninstall. You’ll want to track down where in your startup script this is being overwritten.

For anyone who stumbled upon this issue and the above comments didn’t help, what worked for me is realizing that I was still manually setting $DISPLAY in my .bashrc file. Removing that did the trick.

Big thanks to this redit thread

If I force software rendering with LIBGL_ALWAYS_SOFTWARE=true weston-subsurfaces then the problem does not occur. I have run out of time today but I will try applying this environment variable to the system-distro by following https://github.com/microsoft/wslg/wiki/WSLg-Configuration-Options-for-Debugging to see if that works around Xwayland crashing.

Yes, this works around the problem.

I am unsure whether /usr/lib/wsl/drivers/iigd_dch.inf_amd64_bb614eb89871cffc/libigd12umd64.so is provided by Intel, or whether it is a shim library provided by WSL. If the former, there may not be much WSLg can do here.

I am reliably informed that it is indeed provided by Intel, and is their Windows DirectX driver recompiled for Linux. I wonder if it does some CPU detection on Windows that is not supported on Linux? Perhaps I should be reporting this to Intel, but I don’t know where. The WSLg team may have better contacts for this kind of thing.

In my case /tmp/.X11-unix was a folder too. I’m also using Docker Desktop.

I was able to fix it by adding guiApplications=false in .wslconfig, then wsl --shutdown, removing the line and wsl --shutdown again.

I have a similar issue. It began when I updated the graphics driver on my system as encouraged by https://devblogs.microsoft.com/commandline/wslg-architecture/#hardware-accelerated-opengl.

Details as requested on https://github.com/microsoft/wslg/wiki/Diagnosing-"cannot-open-display"-type-issues-with-WSLg#still-having-a-problem, starting a fresh launch of the container:

wjt@Simulant:/mnt/c/Users/wjt$ cat /mnt/wslg/versions.txt
WSLg ( x86_64 ): 1.0.26+Branch.main.Sha.26ce2c09b86442f3c7f4f6462f770ed2afa76a25
Mariner: VERSION="1.0.20210224"
FreeRDP: b05321cd4e6a862aef76163a69db4e1910245736
weston: 46756d0e77e5c01b5995fbbee6f3ab0db9b30612
pulseaudio: 2f0f0b8c3872780f15e275fc12899f4564f01bd5
mesa:
wjt@Simulant:/mnt/c/Users/wjt$ echo $DISPLAY
:0
wjt@Simulant:/mnt/c/Users/wjt$ ls -la /tmp/.X11-unix
lrwxrwxrwx 1 root root 19 Nov  9 17:12 /tmp/.X11-unix -> /mnt/wslg/.X11-unix
wjt@Simulant:/mnt/c/Users/wjt$ ls -la /tmp/.X11-unix/
total 0
drwxrwxrwx 2 root root   60 Nov  9 17:12 .
drwxrwxrwt 6 root root  260 Nov  9 17:12 ..
srwxrwxrwx 1 wjt  users   0 Nov  9 17:12 X0

OK, great, we see the socket is present. Now, let’s watch /mnt/wslg/weston.log as I start an X11 application:

wjt@Simulant:/mnt/c/Users/wjt$ tail -n0 f /mnt/wslg/weston.log &
[2] 37
wjt@Simulant:/mnt/c/Users/wjt$ glxinfo -B
[17:14:24.899] Spawned Xwayland server, pid 71
[17:14:27.332] xserver crashing too fast: 134
Error: unable to open display :0
[2]+  Done                    tail -n0 f /mnt/wslg/weston.log
wjt@Simulant:/mnt/c/Users/wjt$ ls -la /tmp/.X11-unix/
total 0
drwxrwxrwx 2 root root  40 Nov  9 17:14 .
drwxrwxrwt 6 root root 260 Nov  9 17:12 ..

The socket is gone. I see the same “xserver crashing too fast” warning in @tys203831’s report above. I see they also have a lower-end CPU – mine is a Intel(R) Pentium(R) Silver N5000 CPU @ 1.10GHz.

Ignoring X for a moment, let’s turn to Wayland. Some Wayland applications launch OK, such as weston-flower. But any application that attempts to use GL fails:

wjt@Simulant:/mnt/c/Users/wjt$ weston-subsurfaces
Illegal instruction

Inspecting with GDB, it’s crashing inside the Intel graphics driver:

Program received signal SIGILL, Illegal instruction.
0x00007fffea4cf2d8 in ?? () from /usr/lib/wsl/drivers/iigd_dch.inf_amd64_bb614eb89871cffc/libigd12umd64.so

layout asm shows the offending instruction as vmovaps. Some web searches and pages like this suggests this is part of AVX. But this CPU does not support AVX:

wjt@Simulant:/mnt/c/Users/wjt$ lscpu
Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         39 bits physical, 48 bits virtual
  Byte Order:            Little Endian
CPU(s):                  4
  On-line CPU(s) list:   0-3
Vendor ID:               GenuineIntel
  Model name:            Intel(R) Pentium(R) Silver N5000 CPU @ 1.10GHz
    CPU family:          6
    Model:               122
    Thread(s) per core:  1
    Core(s) per socket:  4
    Socket(s):           1
    Stepping:            1
    BogoMIPS:            2188.79
    Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall n
                         x pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq vmx ssse3 c
                         x16 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave rdrand hypervisor lahf_lm 3dnowprefetch pti ss
                         bd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi ept vpid ept_ad fsgsbase tsc_adjust smep erms rdseed smap clflus
                         hopt sha_ni xsaveopt xsavec xgetbv1 xsaves umip rdpid md_clear arch_capabilities
Virtualization features:
  Virtualization:        VT-x
  Hypervisor vendor:     Microsoft
  Virtualization type:   full
Caches (sum of all):
  L1d:                   96 KiB (4 instances)
  L1i:                   128 KiB (4 instances)
  L2:                    16 MiB (4 instances)
Vulnerabilities:
  Itlb multihit:         Not affected
  L1tf:                  Not affected
  Mds:                   Not affected
  Meltdown:              Mitigation; PTI
  Spec store bypass:     Mitigation; Speculative Store Bypass disabled via prctl and seccomp
  Spectre v1:            Mitigation; usercopy/swapgs barriers and __user pointer sanitization
  Spectre v2:            Mitigation; Enhanced IBRS, IBPB conditional, RSB filling
  Srbds:                 Not affected
  Tsx async abort:       Not affected

If I force software rendering with LIBGL_ALWAYS_SOFTWARE=true weston-subsurfaces then the problem does not occur. I have run out of time today but I will try applying this environment variable to the system-distro by following https://github.com/microsoft/wslg/wiki/WSLg-Configuration-Options-for-Debugging to see if that works around Xwayland crashing.

I am unsure whether /usr/lib/wsl/drivers/iigd_dch.inf_amd64_bb614eb89871cffc/libigd12umd64.so is provided by Intel, or whether it is a shim library provided by WSL. If the former, there may not be much WSLg can do here.

Not sure if it helps anyone, but I had similar issue where wayland application (e.g. gedit) works but X11 application (e.g. xclock/xcalc/firefox/gimp) does not work.

It turns out that if you used your Linux distro before with VcXserv, even after uninstall it, it left something in your Linux distro’s /tmp/.X11-unix folder. The trick is to simply remove this folder, and create a symbolic link to /mnt/wslg/.X11-unix, and everything work now for me.

sudo ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix

I ran into the exact same issue with X11 apps. This resolved it for me. Thanks @yanghao!