1

I am unable to run any of xorg's GUI applications such as xcalc, xclock etc on my local WSL Ubuntu 20.04.2 LTS. On running I am getting the following error message: Error: Can't open display: localhost:0

On running echo $DISPLAY, I get localhost:0. I also tried setting export DISPLAY=':0', which gives the same error: Error: Can't open display: :0

Not sure what I am doing wrong here.

Note: I had set export DISPLAY=localhost:0 in my .bashrc as advised by this page when I was trying to perform X11 forwarding from a remote server to my local machine. But now I'm getting an error even when simply trying to run the above mentioned commands on my local machine.

rtaft
  • 1,825

2 Answers2

1

I had the same problem after upgrade to UBUNTU 22.4

After hour's of searching, dodging all about starting remote sessions over ssh I found this "https://askubuntu.com/a/1128118/910820"
Just like in that scenario my use of echo $DISPLAY returned localhost:0
but when I used who it gave me :1

So a working command for starting xclock given this would be: DISPLAY=:1 xclock&!
Which starts xclock and detaches the process from the terminal
To simplify opening more app's I used export $DISPLAY=:1
now I could use the shorter xclock&! or xeyes&! But only in that session, to make it permanent an edit to sudo nano ~/.bashrc was necessary
I had export DISPLAY=localhost:0 and replaced it with export DISPLAY=:1 and voilá now it stays between reboots What happend during the upgrade from 20.4 to 22.4 that changed my display numbering is beyond me, perhaps someone else could comment on that!
itbojen
  • 51
0

Restarting the terminal did not resolve the issue. However, restarting the machine did somehow resolve the issue.