Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL2 Windows 11 suddenly cannot open display #7950

Closed
1 of 2 tasks
gogog22510 opened this issue Jan 21, 2022 · 14 comments
Closed
1 of 2 tasks

WSL2 Windows 11 suddenly cannot open display #7950

gogog22510 opened this issue Jan 21, 2022 · 14 comments

Comments

@gogog22510
Copy link

Version

Microsoft Windows [Version 10.0.22000.438]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.10.60.1

Distro Version

Ubuntu 20.04

Other Software

No response

Repro Steps

I bought a new Lenovo Legion laptop which came with Windows 11 and I followed this article https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps to install WSL2 and directly running Linux GUI app inside WSL2 which was working fine.
However, not sure what changes, maybe I ran sudo apt update, Linux GUI app stop working anymore due to (gedit:742): Gtk-WARNING **: 22:13:35.300: cannot open display: :0

Simply run any gui command in WSL2

gedit ~/.bashrc
Unable to init server: Could not connect: Connection refused

(gedit:742): Gtk-WARNING **: 22:13:35.300: cannot open display: :0

Expected Behavior

Expected behavior is described in https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps, which is used to work.

Actual Behavior

The GUI keep complaining cannot open display, even though I tried some solution listed here to get the actual ip, still has no hope.

Diagnostic Logs

No response

@gogog22510
Copy link
Author

Just found something not sure is related. With ipconfig I can see vEthernet (WSL) in the console log, however, I cannot find it in the Settings > Network Adapter in Windows 11. However, in my another laptop which is running Windows 10. I can see the adapter.

@eqn-group
Copy link

eqn-group commented Jan 25, 2022

It is an issue with an environment variable that is needed to point to the host machines IP.
try the command "wsl --update" , "wsl --shutdown"
then open it back.

If doesn't work take a look at #6430

@gogog22510
Copy link
Author

Unfortunately, "wsl --update" and "wsl --shutdown" doesn't work for me... I tried to set export DISPLAY="$(grep nameserver /etc/resolv.conf | sed 's/nameserver //'):0" as suggested in #6430, however, still not working.
I saw some comment mention adding a new firewall rule for %ProgramFiles%\VcXsrv\vcxsrv.exe, but I'm in Windows 11 which I don't think I have this exe nor needed install XSwing.

@ikhid3
Copy link

ikhid3 commented Mar 24, 2022

Try following the steps outlined here https://github.com/microsoft/wslg/wiki/Diagnosing-%22cannot-open-display%22-type-issues-with-WSLg

I was able to get it working using this!

@phetdam
Copy link

phetdam commented Jul 5, 2022

I followed the steps outlined in this link as a workaround, which I originally tested using WSL 1 on a Windows 10 Home build 19044.1766 Dell Inspiron 15 5000, but which also worked for WSL 2 on a Windows 11 Home build 22000.739 HP Envy. The link does say that you should follow the WSL 2 guide instead if you use WSL 2, but the WSL 1 guide actually works as well.

The summary is to have DISPLAY=:0 set in your .bashrc, source the .bashrc to apply the change, and to make sure XLaunch from your VcXsrv installation is running (default settings is fine). You'll probably see warnings being printed to stderr in your WSL Linux shell window, but the GUI apps should display properly. Ex. xeyes will show the eyes, xcalc will show the calculator.

@mpontiveros
Copy link

I followed the steps outlined in this link as a workaround, which I originally tested using WSL 1 on a Windows 10 Home build 19044.1766 Dell Inspiron 15 5000, but which also worked for WSL 2 on a Windows 11 Home build 22000.739 HP Envy. The link does say that you should follow the WSL 2 guide instead if you use WSL 2, but the WSL 1 guide actually works as well.

The summary is to have DISPLAY=:0 set in your .bashrc, source the .bashrc to apply the change, and to make sure XLaunch from your VcXsrv installation is running (default settings is fine). You'll probably see warnings being printed to stderr in your WSL Linux shell window, but the GUI apps should display properly. Ex. xeyes will show the eyes, xcalc will show the calculator.

Tried this as well. Thank you!

@kasvith
Copy link

kasvith commented Dec 3, 2022

Im also having the same issue in W10

@SEELE0
Copy link

SEELE0 commented Jan 5, 2023

I also followed this article https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps
but i can't also have the same issue ,even i never make it work succees.
could you answer some of my questions:Do I need to configure additional ip for connection? Can the operation of this article reproduce a complete ubuntu desktop?

@SEELE0
Copy link

SEELE0 commented Jan 5, 2023

@phetdam 你好我想询问一下就是这篇官方教程中并未提到配置ip打开防火墙之类的操作
https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps
这是因为一般情况下这些默认设置是不会报错吗?
另外我想请教一下通过这种方式能否做到实现一个完整的ubuntu桌面窗口就像是在vmware里安装的ubuntu桌面一样。

@gogog22510
Copy link
Author

Previously I ran the sudo apt upgrade and sudo apt update which may have updated something and broke the network configuration. I eventually reinstall Ubuntu 20.04 in WSL2 which resolved the issue.

@phetdam
Copy link

phetdam commented Jan 6, 2023

@phetdam 你好我想询问一下就是这篇官方教程中并未提到配置ip打开防火墙之类的操作 https://docs.microsoft.com/en-us/windows/wsl/tutorials/gui-apps 这是因为一般情况下这些默认设置是不会报错吗? 另外我想请教一下通过这种方式能否做到实现一个完整的ubuntu桌面窗口就像是在vmware里安装的ubuntu桌面一样。

细节我不太清楚,我只用了VcXsrv + WSL1,没有花时间仔细看。
I'm not too clear, I only used VcXsrv + WSL1 and didn't spend too much time on it.

I don't think it's possible to achieve complete Ubuntu desktop however, as the X11 forwarding works on per-application basis. Unless there is a "desktop" program, maybe then it's ok; not sure about performance.

@SEELE0
Copy link

SEELE0 commented Jan 6, 2023

@phetdam你好我想问一下就是这篇官方教程中并没有提供到配置ip打开防火墙之类的操作https://docs.microsoft.com/zh-cn/windows/wsl/tutorials/gui-apps这是因为一般情况下这些默认设置是不会报错的吗?另外我想请教一下通过这种方式不能做到现在一个完整的ubuntu面板窗口就像一个嵌套ubuntu在vmware里面。

细节我不太清楚,我只用了VcXsrv + WSL1,没有花时间仔仔细看。 我也不太清楚,我只用了VcXsrv + WSL1,也没有花太多时间在上面。

然而,我认为不可能实现完整的 Ubuntu 桌面,因为 X11 转发是在每个应用程序的基础上工作的。除了不是有一个“桌面”程序,否则不容许就可以了;

@phetdam 大致了解了,感谢

@bhanuunrivalled
Copy link

HI All,

this link says

https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps

You will need to be on Windows 10 Build 19044+

this is my windows version

ver

Microsoft Windows [Version 10.0.19045.2604]

but still i have this error

gedit ~/.bashrc
Unable to init server: Could not connect: Connection refused

(gedit:508): Gtk-WARNING **: 09:51:14.444: cannot open display:

@gogog22510 is this working for you?

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants