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 can't open display #6181

Closed
peter-jerry-ye opened this issue Nov 1, 2020 · 10 comments
Closed

WSL2 can't open display #6181

peter-jerry-ye opened this issue Nov 1, 2020 · 10 comments

Comments

@peter-jerry-ye
Copy link

Environment

Windows build number: 10.0.19041.0
Your Distribution version: Ubuntu 20.04
Whether the issue is on WSL 2 and/or WSL 1: WSL2

Steps to reproduce

  • Install VcXSrv
  • Go to Windows Defender Firewall to enable all network connection for VcXSrv
  • Start VcXsrv with "Multiple windows", "Start no client", enable every option (including Disable access control)
  • run ip route to get ip of host os, which is default via 172.30.96.1 dev eth0
  • run DISPLAY=172.30.96.1:0.0 xeyes to test xserver

https://gist.github.com/peter-jerry-ye/725d6768fde7a5c37294ce9faf70bbb4

WSL logs:

Expected behavior

Xeyes being started

Actual behavior

Error: Can't open display: 172.30.96.1:0.0 after a few seconds

@luochen1990
Copy link

Check which address your VcXSrv is listening, by hover the tray icon of VcXSrv, it could be hostname:x.0 and you should check x is 0

@peter-jerry-ye
Copy link
Author

Check which address your VcXSrv is listening, by hover the tray icon of VcXSrv, it could be hostname:x.0 and you should check x is 0

It' s listening at "hostname:0.0", and with the ip adresse shown in ip route, it doesn't work.

@onomatopellan
Copy link

Go to Windows Defender Firewall to enable all network connection for VcXSrv

Maybe that's not enough. Close everything and go to Windows Firewall with Advanced Security -> Inbound rules and delete every rule you see for Vcxsvr.exe. After that the first time you launch Vcxsvr make sure you Allow access for Private AND Public networks.

@peter-jerry-ye
Copy link
Author

Go to Windows Defender Firewall to enable all network connection for VcXSrv

Maybe that's not enough. Close everything and go to Windows Firewall with Advanced Security -> Inbound rules and delete every rule you see for Vcxsvr.exe. After that the first time you launch Vcxsvr make sure you Allow access for Private AND Public networks.

It works! Thanks a lot.

@varadhraj
Copy link

@peter-jerry-ye works like a charm. thanks.

@jha-prateek
Copy link

Go to Windows Defender Firewall to enable all network connection for VcXSrv

Maybe that's not enough. Close everything and go to Windows Firewall with Advanced Security -> Inbound rules and delete every rule you see for Vcxsvr.exe. After that the first time you launch Vcxsvr make sure you Allow access for Private AND Public networks.

It works!

@hongbo-zhu-cn
Copy link

Go to Windows Defender Firewall to enable all network connection for VcXSrv

Maybe that's not enough. Close everything and go to Windows Firewall with Advanced Security -> Inbound rules and delete every rule you see for Vcxsvr.exe. After that the first time you launch Vcxsvr make sure you Allow access for Private AND Public networks.

Or double click the VcXsrv rules and change action to "Allow the connection" .

@scotinus
Copy link

Go to Windows Defender Firewall to enable all network connection for VcXSrv

Maybe that's not enough. Close everything and go to Windows Firewall with Advanced Security -> Inbound rules and delete every rule you see for Vcxsvr.exe. After that the first time you launch Vcxsvr make sure you Allow access for Private AND Public networks.

Or double click the VcXsrv rules and change action to "Allow the connection" .

Thank you, thank you @jha-prateek and @hongbo-zhu-cn. I finally got there with a combination of these answers. Enabling inbound PUBLIC networks was the key.

@RorisangSitoboli
Copy link

  • Open Xlaunch as an 'administrator' in your host (Windows). Right click on the app and select that option.
  • If you happen to see a '-1' near the bottom of the XLaunch first page, you can smile already.
  • Choose option that disables 'control'. forgot on what page of the set up GUI it is on (maybe two).
  • Launch WSL.
  • Type exactly this as I am not using placeholders: 'export DISPLAY="$(grep nameserver /etc/resolv.conf | sed 's/nameserver //'):0"
  • Test in Ubuntu by typing: 'xcalc'
  • Make sure you have browser installed if you go online with a GUI.
  • Good luck.

@javierportillo
Copy link

Hey guys, I found another solution if you are still not getting results.
If you're using ip route to get the host IP be careful with that command introducing invicible color codes to the output.
You can install colorized-logs package in ubuntu and use the ansi2txt tool to clean the output of ip route like this:
DISPLAY=$(ip route list exact default | awk '{print $3}' | ansi2txt):0
This solved it for me.

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

9 participants