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
- 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. - Install Intel GPU driver for WSL (Note: CsProcessors: {Intel® Celeron® N4000 CPU @ 1.10GHz}, Integrated GPU: {Intel® UHD Graphics 600} and no dedicated gpu)
- Run
sudo apt update && sudo apt upgrade
in wsl terminal - Install x11-apps
- Run xcalc or xeyes in windows terminal through
wsl xeyes
. (Note: when I runxeyes
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
- 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
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)
then open windows command prompt and restart WSL I did
wsl --shutdown
then restarted wsl by re-opening my wsl clientHello @tys203831. It looks like your DISPLAY environment variable is incorrectly set… it should be set to
:0
and not172.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
Yes, this works around the problem.
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
, thenwsl --shutdown
, removing the line andwsl --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:
OK, great, we see the socket is present. Now, let’s watch
/mnt/wslg/weston.log
as I start an X11 application: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:
Inspecting with GDB, it’s crashing inside the Intel graphics driver:
layout asm
shows the offending instruction asvmovaps
. Some web searches and pages like this suggests this is part of AVX. But this CPU does not support AVX: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.I ran into the exact same issue with X11 apps. This resolved it for me. Thanks @yanghao!