≡ Menu

xhost+ : How to Fix “Cannot Open Display” Error While Launching GUI on Remote Server

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.

Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • hari June 25, 2010, 9:10 am

    is
    # xhost –
    will block from using X server from remote login to this system?

    for ex:
    system1 # xhost –
    system2 # ssh -X system1
    system1 # gedit new.txt
    it opening a new file, it not blocking X server.

  • Jeff June 25, 2010, 9:39 am

    love this site, love these articles but xhost? pfft!

    hari, when you’re X11 forwarding, you aren’t using xhost for X authentication. the client is using xauth authentication mechanism. the server and client share a secret “cookie”(xauth list to see yours)…. google xauth howto comes up with a lot of references

  • thib June 25, 2010, 11:53 am

    Unless the network environment is entirely controlled, xhost is a very bad idea [1]. Prefer xauth [2] or other mechanisms. See the Remote X Apps mini-HOWTO for details [3]. (My understanding.)

    1: http://www-it.desy.de/systems/services/x11/xsec.html
    2: http://www.acm.uiuc.edu/workshops/cool_unix/xauth.html
    3: http://tldp.org/HOWTO/Remote-X-Apps.html

  • Slappy June 25, 2010, 6:37 pm

    xhost is a security nightmare. Just use “ssh -X name@serveripaddress”, then type the name of the progam you want to use.

  • Pavi October 17, 2011, 6:03 am

    Really good information. It worked for me.
    but If I want to open GUI application on my host which is installed on other host.
    Suppose no browsers are installed on my host and if i want to open browser which is installed on other host, how can i do this.
    In this case, which host’s IP will be considered for opening sites?mine or accessed?
    i hope you understand, what i want to know.
    Thanks

  • naveen January 4, 2012, 7:53 am

    rly good solution ..its worked for me

  • Rashid December 6, 2013, 3:23 am

    i install geany and when run it got below error. even i update gtk2 and all depended lib. also export DISPLAY=’IP:0.0′ with local ip, can any one help me to remove this error to run geany
    #geany
    Geany: cannot open display

  • Peter June 29, 2014, 3:26 am

    xhost+ solved it for me, using vnc into a Wheezy headless server.

    Thank you for the fix, this has been annoying me for a while now!

  • anil kumar November 6, 2014, 10:56 am

    i am trying to connect the IBM P740 system via xmanager , for oracle installation .
    But i am not able to connect i get “XDMCP connection failed. Try again?”
    I have done xhost+ & also set the DISPLAY env variable.
    $ echo $DISPLAY
    10.217.108.64:0.0
    Help me how to enable the remote administration for AIX machine.

  • Doug Somers March 18, 2015, 4:46 pm

    Also encountered this error and finally came up with a fix that works for Solaris 10.
    The listener was not set to listen. After setting it to true, it works just fine.

    svccfg –s /application/x11/x11-server listprop options/tcp_listen
    svccfg –s /application/x11/x11-server setprop options/tcp_listen = true

  • Shah June 17, 2015, 5:03 pm

    Thank you! 😀

  • Ramyabandaraherath March 4, 2017, 11:39 pm

    Please my display open

  • comrade April 27, 2017, 10:17 am

    Slappy – best solution, thanks!