Question: When I try to launch any GUI application on a remote server, I’m getting the “cannot open display:” error, as shown below. How do I fix this?
For example, while launching the gedit on remote server, I got the following message.
(gedit:3658): Gtk-WARNING **: cannot open display:
I get similar message when I try to open any GUI application. For example, launching Oracle Installer on remote server also gives the “cannot open display” error.
Answer: You can fix the “cannot open display” error by following the xhost procedure mentioned in this article.
1. Allow clients to connect from any host using xhost+
Execute the following command to disable the access control, by which you can allow clients to connect from any host.
$ xhost + access control disabled, clients can connect from any host
2. Enable X11 forwarding
While doing ssh use the option -X to enable X11 forwarding.
$ ssh username@hostname -X
Enable trusted X11 forwarding, by using the -Y option,
$ ssh username@hostname -Y
3. Open GUI applications in that host
After opening ssh connection to the remote host as explained above, you can open any GUI application which will open it without any issue.
If you still get the “cannot open display” error, set the DISPLAY variable as shown below.
$ export DISPLAY='IP:0.0'
Note: IP is the local workstation’s IP where you want the GUI application to be displayed.
Get the Linux Sysadmin Course Now!