The Computer Oracle

Error: Can't open display: 0

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Fantascape Looping

--

Chapters
00:00 Error: Can'T Open Display: 0
00:35 Accepted Answer Score 47
01:11 Answer 2 Score 13
01:51 Answer 3 Score 0
02:18 Answer 4 Score 3
02:43 Thank you

--

Full question
https://superuser.com/questions/1476086/...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#windows #windows10 #windowssubsystemforlinux #xming

#avk47



ACCEPTED ANSWER

Score 47


Solved problem with executing this command

export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0

This command can also be added in shell initialization files, for example, .bashrc, .zshrc etc.

Also make sure to allow public access of X server running in Windows 10. For VcXsrv, -ac option is most important because it allows public access. For Xming, run through XLaunch and in the part "Specify parameter settings" select "No Access Control".

For more see this discussion Microsoft/WSL: Can't use X-Server in WSL2.




ANSWER 2

Score 13


I encountered this issue after changing the version of my WSL Ubuntu distribution from 1 to 2. Using

export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0

was not sufficient. According to https://github.com/microsoft/WSL/issues/6181 I needed to reconfigure the firewall. This can be done by

  • going to Advanced Security -> Inbound rules (admin permissions required)
  • delete all rules for Vcxsvr
  • restarting Vcxsvr, which prompts you to set Windows Firewall for this program
  • allow all (or enough) access

After these 2 changes, the problem was solved.




ANSWER 3

Score 3


Follow these steps:

  1. Open PowerShell as Administrator and run: New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow

  2. Now open WSL2 and run: export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0

  3. Now xeyes




ANSWER 4

Score 0


For coLinux using eth0=slirp with the default configuration, Xming on the Windows host can be accessed using export DISPLAY=10.0.2.2:0 (or 0.0). Using biswapriyo's solution would not work in this case because slirp sets the resolver IP to 10.0.2.3, but his answer made me realize what I was doing wrong.