LoginSignup
1
0

More than 1 year has passed since last update.

WSL2のWSLg環境で could not connect to display :0 が出るようになったときの対処法

Last updated at Posted at 2022-08-27

不具合

何日か前から別のマシン上にある複数のWSL2環境でGUIアプリを使おうとすると

qt.qpa.xcb: could not connect to display :0
や
Display :0 unavailable

のようなエラーが頻発するようになった。何回か再起動をしたら治ったりする。

暫定的な対処法

根本的な要因はわからないが、特に何も指定していなければ

$ echo $DISPLAY
:0

となっているはずだが、/tmp/.X11-unix/mnt/wslg/.X11-unixの中身が本来はX0があるべき箇所に

$ ls /tmp/.X11-unix
X3
$ ls /mnt/wslg/.X11-unix
X3

など場合によっては他の数値のソケットファイルがなぜかできるようになっていた。

暫定的な対処法としてX3ができていたら

$ export DISPLAY=:3
$ echo $DISPLAY
:3

とすれば再びGUIアプリが表示できるようになる。

追記

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0