1

I am having trouble with graphical applications and WSL. I have Ubuntu 20.04.3 with X11 installed; but am getting the following issue when I try to test with xeyes (the same happens with any other graphical application I use).

xeyes
Error: Can't open display: localhost:0.0

I have been reading up online about similar problems but have not yet found a solution. I am using a VcXsrv X Server (and have tried Xming too previously).

I have tried changing the display using all of the following independently:

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

None of which are working.

I have checked to make sure the X server is being allowed through the firewall and it is.

I also went into /etc/ssh/sshd_config and changed the following:

X11Forwarding yes

I did try ~/.profile, which returned -bash: /.profile: No such file or directory

I have also set up a PuTTY configuration with X11 forwarding enabled.

Finally, I tried the following:

export DISPLAY=$(route.exe print | grep 0.0.0.0 | head -1 | awk '{print $4}'):0.0

Once again, this did not work. However, it did change the IP to a different one from all the previous attempts and then threw the following error:

Authorization required, but no authorization protocol specified
Error: Can't open display: 

I am not sure if this is progress or not, maybe now all that is standing in my way is this authorisation.

I have seen people online saying to run: vcxsrv -ac to change the access controls of the X Server, but then others say not to do it because it can compromise security. I am only running this locally but don't really know what I am doing so have not done it.

I know this problem is quite common from the amount of forums I have been on, so am not expecting someone to instant fix this for me. But I would appreciate if someone could point me in the right direction based on any of the information I have provided, because it seems I have covered most if not all of the solutions that I can find on other forums.

Thanks in advance :)

Edit

Since posting, I have come to the conclusion that the following was the correct display setting:
export DISPLAY=$(route.exe print | grep 0.0.0.0 | head -1 | awk '{print $4}'):0.0

And I have just opted to disable the access control setting on vcxsrv, now when I run xeyes I get the following error:

XIO:  fatal IO error 104 (Connection reset by peer) on X server "IP:0.0"
      after 171 requests (171 known processed) with 0 events remaining.

I assume this means the X11 forwarding is not working correctly? but I am not sure what to do to fix it.

Edit #2

I have decided to upgrade to windows 11 because after reading up on it, I have seen that WSL2 on windows 11 has this X server dealt with already, so no need to mess around with xming etc.

After upgrading to windows 11 and updating WSL2, I have been able to use gedit successfully with a graphical interface. However, I am still getting the same:

Error: Can't open display:

when I attempt to run xeyes and some other graphical interfaces. I am fairly confident gedit was not working before I upgraded to Windows 11, so this update has partially fixed my problem, though not completely

5
  • What version of wsl are you running ? Try upgrading it by opening an administrative powershell and using 'wsl --update' and restarting.
    – Silbee
    Commented Oct 14, 2021 at 21:44
  • I just did the upgrade as suggested and it still does not work. Also, its wsl version 2
    – George
    Commented Oct 14, 2021 at 21:52
  • Which WSL version? 1 or 2? I use it just fine with WSL1 and VcXSrv. Xeyes should be fine but i use the old school xterm to test the basic functionality. You show several export commands but nothing showing what actually got into the variable. For me, I see this: echo $DISPLAY <newline_here>127.0.0.1:0.0 and xterm & fires up an old school console. I set the DISPLAY variable in my .bashrc. Commented Oct 15, 2021 at 0:43
  • Sorry.. I was too stupid to read your comment about WSL2. Shouldn't matter though, just make sure you have the correct IP set. There is nothing magic about WSL. With 2, you just need to treat it as if it were another Linux box. Commented Oct 15, 2021 at 0:46
  • I did read that WSL2 is different and you need to use this: export DISPLAY=$(route.exe print | grep 0.0.0.0 | head -1 | awk '{print $4}'):0.0 rather than localhost.
    – George
    Commented Oct 15, 2021 at 9:17

2 Answers 2

1

Upgrading to windows 11 has solved my problem. the problem I was getting in 'Edit #2' was caused by a line I had left in my bashrc from attempts to fix my previous problem.

0

For the sake of completeness I would like to take the opportunity to mention that it is possible to make this work on Win10 with the help of x410 in a stable manner using vsock.

Read here (still SuperUser) if you want to know how I did it: running gui with x410 and wsl

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .