How do I fix a “cannot open display” error when opening an X program after ssh'ing with X11 forwarding...











up vote
87
down vote

favorite
39












After launching the X11 app (XQuartz 2.3.6, xorg-server 1.4.2-apple56) on my Mac (OS X 10.6.8), opening an terminal in X11 and running xhost +, I then ssh -Y to my Ubuntu 10.04 VM (running on VMware Fusion). When I run gedit .bashrc (for example), I get:



(gedit:9510): Gtk-WARNING **: cannot open display: 


set | grep DISPLAY returns nothing.



But if I ssh -Y into my Ubuntu 11.04 machine, gedit .bashrc works. echo $DISPLAY returns "localhost:10.0".



I tried export DISPLAY=localhost:10.0 while sshed into my VM and then running gedit .bashrc, but I get:



(gedit:9625): Gtk-WARNING **: cannot open display: localhost:10.0


What could be different in the configuration of the two difference Ubuntu machines that would explain why one works and the other doesn't?



Update: As suggested by Zoredache in the comment below, I ran sudo apt-get install xbase-clients, but I continue to have the same problem.










share|improve this question















migrated from serverfault.com Jul 13 '11 at 18:31


This question came from our site for system and network administrators.











  • 2




    Does the Ubuntu 10.04 box have the proper tools for X11 installed? Install xbase-clients, if it isn't installed already.
    – Zoredache
    Jul 13 '11 at 18:22










  • I installed it but still have the same problem. (See above.)
    – Daryl Spitzer
    Jul 13 '11 at 18:29










  • Yes. Just to be sure, I restarted the VM (and reconnected through SSH afterward).
    – Daryl Spitzer
    Jul 13 '11 at 18:38






  • 3




    Maybe try passing the -vv option to ssh when you connect, this prints verbose debug messages, you should see several comments about X11 forwarding while connecting.
    – Zoredache
    Jul 13 '11 at 18:43






  • 1




    In my case it was just a matter of upgrading the XQuartz version of MacOS
    – Waruna Ranasinghe
    Dec 29 '16 at 18:20















up vote
87
down vote

favorite
39












After launching the X11 app (XQuartz 2.3.6, xorg-server 1.4.2-apple56) on my Mac (OS X 10.6.8), opening an terminal in X11 and running xhost +, I then ssh -Y to my Ubuntu 10.04 VM (running on VMware Fusion). When I run gedit .bashrc (for example), I get:



(gedit:9510): Gtk-WARNING **: cannot open display: 


set | grep DISPLAY returns nothing.



But if I ssh -Y into my Ubuntu 11.04 machine, gedit .bashrc works. echo $DISPLAY returns "localhost:10.0".



I tried export DISPLAY=localhost:10.0 while sshed into my VM and then running gedit .bashrc, but I get:



(gedit:9625): Gtk-WARNING **: cannot open display: localhost:10.0


What could be different in the configuration of the two difference Ubuntu machines that would explain why one works and the other doesn't?



Update: As suggested by Zoredache in the comment below, I ran sudo apt-get install xbase-clients, but I continue to have the same problem.










share|improve this question















migrated from serverfault.com Jul 13 '11 at 18:31


This question came from our site for system and network administrators.











  • 2




    Does the Ubuntu 10.04 box have the proper tools for X11 installed? Install xbase-clients, if it isn't installed already.
    – Zoredache
    Jul 13 '11 at 18:22










  • I installed it but still have the same problem. (See above.)
    – Daryl Spitzer
    Jul 13 '11 at 18:29










  • Yes. Just to be sure, I restarted the VM (and reconnected through SSH afterward).
    – Daryl Spitzer
    Jul 13 '11 at 18:38






  • 3




    Maybe try passing the -vv option to ssh when you connect, this prints verbose debug messages, you should see several comments about X11 forwarding while connecting.
    – Zoredache
    Jul 13 '11 at 18:43






  • 1




    In my case it was just a matter of upgrading the XQuartz version of MacOS
    – Waruna Ranasinghe
    Dec 29 '16 at 18:20













up vote
87
down vote

favorite
39









up vote
87
down vote

favorite
39






39





After launching the X11 app (XQuartz 2.3.6, xorg-server 1.4.2-apple56) on my Mac (OS X 10.6.8), opening an terminal in X11 and running xhost +, I then ssh -Y to my Ubuntu 10.04 VM (running on VMware Fusion). When I run gedit .bashrc (for example), I get:



(gedit:9510): Gtk-WARNING **: cannot open display: 


set | grep DISPLAY returns nothing.



But if I ssh -Y into my Ubuntu 11.04 machine, gedit .bashrc works. echo $DISPLAY returns "localhost:10.0".



I tried export DISPLAY=localhost:10.0 while sshed into my VM and then running gedit .bashrc, but I get:



(gedit:9625): Gtk-WARNING **: cannot open display: localhost:10.0


What could be different in the configuration of the two difference Ubuntu machines that would explain why one works and the other doesn't?



Update: As suggested by Zoredache in the comment below, I ran sudo apt-get install xbase-clients, but I continue to have the same problem.










share|improve this question















After launching the X11 app (XQuartz 2.3.6, xorg-server 1.4.2-apple56) on my Mac (OS X 10.6.8), opening an terminal in X11 and running xhost +, I then ssh -Y to my Ubuntu 10.04 VM (running on VMware Fusion). When I run gedit .bashrc (for example), I get:



(gedit:9510): Gtk-WARNING **: cannot open display: 


set | grep DISPLAY returns nothing.



But if I ssh -Y into my Ubuntu 11.04 machine, gedit .bashrc works. echo $DISPLAY returns "localhost:10.0".



I tried export DISPLAY=localhost:10.0 while sshed into my VM and then running gedit .bashrc, but I get:



(gedit:9625): Gtk-WARNING **: cannot open display: localhost:10.0


What could be different in the configuration of the two difference Ubuntu machines that would explain why one works and the other doesn't?



Update: As suggested by Zoredache in the comment below, I ran sudo apt-get install xbase-clients, but I continue to have the same problem.







ssh display xorg gtk






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 13 '17 at 12:14









Community

1




1










asked Jul 13 '11 at 18:13









Daryl Spitzer

3,860103536




3,860103536




migrated from serverfault.com Jul 13 '11 at 18:31


This question came from our site for system and network administrators.






migrated from serverfault.com Jul 13 '11 at 18:31


This question came from our site for system and network administrators.










  • 2




    Does the Ubuntu 10.04 box have the proper tools for X11 installed? Install xbase-clients, if it isn't installed already.
    – Zoredache
    Jul 13 '11 at 18:22










  • I installed it but still have the same problem. (See above.)
    – Daryl Spitzer
    Jul 13 '11 at 18:29










  • Yes. Just to be sure, I restarted the VM (and reconnected through SSH afterward).
    – Daryl Spitzer
    Jul 13 '11 at 18:38






  • 3




    Maybe try passing the -vv option to ssh when you connect, this prints verbose debug messages, you should see several comments about X11 forwarding while connecting.
    – Zoredache
    Jul 13 '11 at 18:43






  • 1




    In my case it was just a matter of upgrading the XQuartz version of MacOS
    – Waruna Ranasinghe
    Dec 29 '16 at 18:20














  • 2




    Does the Ubuntu 10.04 box have the proper tools for X11 installed? Install xbase-clients, if it isn't installed already.
    – Zoredache
    Jul 13 '11 at 18:22










  • I installed it but still have the same problem. (See above.)
    – Daryl Spitzer
    Jul 13 '11 at 18:29










  • Yes. Just to be sure, I restarted the VM (and reconnected through SSH afterward).
    – Daryl Spitzer
    Jul 13 '11 at 18:38






  • 3




    Maybe try passing the -vv option to ssh when you connect, this prints verbose debug messages, you should see several comments about X11 forwarding while connecting.
    – Zoredache
    Jul 13 '11 at 18:43






  • 1




    In my case it was just a matter of upgrading the XQuartz version of MacOS
    – Waruna Ranasinghe
    Dec 29 '16 at 18:20








2




2




Does the Ubuntu 10.04 box have the proper tools for X11 installed? Install xbase-clients, if it isn't installed already.
– Zoredache
Jul 13 '11 at 18:22




Does the Ubuntu 10.04 box have the proper tools for X11 installed? Install xbase-clients, if it isn't installed already.
– Zoredache
Jul 13 '11 at 18:22












I installed it but still have the same problem. (See above.)
– Daryl Spitzer
Jul 13 '11 at 18:29




I installed it but still have the same problem. (See above.)
– Daryl Spitzer
Jul 13 '11 at 18:29












Yes. Just to be sure, I restarted the VM (and reconnected through SSH afterward).
– Daryl Spitzer
Jul 13 '11 at 18:38




Yes. Just to be sure, I restarted the VM (and reconnected through SSH afterward).
– Daryl Spitzer
Jul 13 '11 at 18:38




3




3




Maybe try passing the -vv option to ssh when you connect, this prints verbose debug messages, you should see several comments about X11 forwarding while connecting.
– Zoredache
Jul 13 '11 at 18:43




Maybe try passing the -vv option to ssh when you connect, this prints verbose debug messages, you should see several comments about X11 forwarding while connecting.
– Zoredache
Jul 13 '11 at 18:43




1




1




In my case it was just a matter of upgrading the XQuartz version of MacOS
– Waruna Ranasinghe
Dec 29 '16 at 18:20




In my case it was just a matter of upgrading the XQuartz version of MacOS
– Waruna Ranasinghe
Dec 29 '16 at 18:20










14 Answers
14






active

oldest

votes

















up vote
33
down vote



accepted










Check the server's sshd_config (normally /etc/ssh/sshd_config), and make sure the X11Forwarding option is enabled with the line



X11Forwarding yes


If X11Forwarding is not specified, the default is no on the Debian machines I have available to check.






share|improve this answer



















  • 4




    I discovered after setting up another Ubuntu VM, that I need to both install xbase-clients and enable X11Forwarding. Update your answer to include both and I'll accept it.
    – Daryl Spitzer
    Jul 13 '11 at 19:21






  • 1




    Interesting. At least on the new install of 10.04 that I did this morning X11Forwarding was enabled by default. The Ubuntu guys must be messing around with defaults again.
    – Zoredache
    Jul 13 '11 at 19:50






  • 15




    @DerfK, in my system "X11Forwarding yes" was there already still I am getting error as, (gedit:8381): Gtk-WARNING **: cannot open display: in such cases
    – A J
    Oct 6 '15 at 8:30










  • On Debian you might have to install package xauth, then log again.
    – comte
    Aug 7 at 9:40


















up vote
50
down vote













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




Answer: You can fix the “cannot open display” error by following the xhost procedure mentioned in this article.



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



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


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.







share|improve this answer



















  • 7




    +1 for the Note that IP = is the local workstation's IP where you want to get the GUI
    – PCoder
    Nov 2 '13 at 10:15






  • 3




    For those having similar issues on OS X, also make sure you have XQuartz installed, otherwise none of these fixes help. (OP's question shows he has XQuartz, so this is more a side note to those having similar issues as I was)
    – Dolan Antenucci
    May 28 '14 at 21:49






  • 2




    Note that running xhost + is very unsecure and should not be used! As Stefan Rogin mentioned, the attacker can then from the host connect to your XSession, read all you type, or even alter the screen you see.
    – jirislav
    May 13 at 8:38




















up vote
17
down vote













I've had this problem when logging into a Ubuntu VM from Mac OS X as well -- it doesn't seem to like 'localhost' in the display variable for some reason. So set the IP manually, as harrymc suggests:



export DISPLAY="127.0.0.1:10.0"


Then X11 programs should be fine. It doesn't seem like it should be necessary to tell the OS that localhost and 127.0.0.1 are equivalent, but it works, at least.






share|improve this answer





















  • This worked for me. Any idea why localhost wasn't working?
    – Alex
    Sep 24 '13 at 4:47






  • 2




    BINGO! I've been stuck by that problem for some time... I connected by SSH and couldn't launch Gtk programs (plain X11, like "xeyes", worked however). DISPLAY was correct. Actually, the resolution of "localhost" wasn't! If I set manually DISPLAY=127.0.0.1:10.0, or DISPLAY=::1:10.0 it does work. Editing /etc/hosts seems to have no effect; and DNS is correctly configured ("dig localhost" correclty report both 127.0.0.1 and ::1) So, it seems to be a bug in whatever does DNS resolution for X11 connections in Gtk (gtk? gdk? glib? other?).
    – Pablo Saratxaga
    Feb 9 '14 at 11:38








  • 1




    On a Debian install for the Beagle Bone Black, /etc/host was not set to readable by anyone but root. This caused the symptoms reported here. Made /etc/hosts readable by all, and it worked fine.
    – Daniel
    Mar 6 '16 at 2:00


















up vote
13
down vote













I had this problem with my CentOS KVM server, I was missing the "xauth" program.






share|improve this answer

















  • 1




    This helped me out on my minimal debian installation, thank you very much!
    – binOr
    Jan 16 '13 at 9:44


















up vote
9
down vote













If you have this problem after some time when running with -X arg. or just ForwardX11 in /etc/ssh/ssh_config, then run $ ssh username@hostname -Y, to enable trusted X11 forwarding, don't know the exact cause but I'm guessing with -X some features expire after some time, probably to increase security.



Here is what I found online :




If you use ssh -X remotemachine the remote machine is treated as an
untrusted client. So your local client sends a command to the remote
machine and receives the graphical output. If your command violates
some security settings you'll receive an error instead.



But if you use ssh -Y remotemachine the remote machine is treated as
trusted client. This last option can open security problems. Because
other graphical (X11) client could sniff data from the remote machine
(make screenshots, do keylogging and other nasty stuff) and it is even
possible to alter those data.



If you want to know more about those things I suggest reading the
Xsecurity manpage or the X Security extension spec. Furthermore you
can check the options ForwardX11 and ForwardX11Trusted in your
/etc/ssh/ssh_config.




sources:




  • what is the difference between ssh -Y and ssh -X

  • cygwin/X warning: could not open X display






share|improve this answer






























    up vote
    4
    down vote













    When running UXTERM or XTERM just issue



    export $DISPLAY 


    The variable will be there. Then just set it and export it.






    share|improve this answer






























      up vote
      4
      down vote













      Just Tested On My Mac, Other Systems Might Be OK:




      1. Allow clients to connect from any host using xhost+


        $ xhost +




      2. You should have an environment that support X11 display


        [Mac System] Install X11 for mac https://www.xquartz.org/




      3. You should let your ssh-server forward x11 display


        update /etc/ssh/sshd_config and set X11Forwarding yes, then restart your ssh server




      4. You should let your ssh session forward x11 display with -X parameter


        $ ssh -X user@ip




      5. How to open X11 app in PyCharm?



        • open a ssh session that support X11 display(remember to keep this session)

        • run echo $DISPLAY in that ssh session

        • set DISPLAY environment variable for your PyCharm









      share|improve this answer



















      • 1




        Why is this different or why should it be preferred over any of the other answer? Please explain if you can with a simple edit. You can do it!!
        – Pimp Juice IT
        Aug 30 '17 at 12:34










      • @McDonald's Thanks, updated with more details.
        – Color
        Sep 4 '17 at 2:58


















      up vote
      2
      down vote













      I also had this problem with Solaris 10 and found that the listener was not set up.



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





      share|improve this answer






























        up vote
        2
        down vote













        I had to put in /etc/ssh/sshd_config the following:



        X11UseLocalhost no


        Rather then setting it "yes". Strange if the default is "NO"
        Users using putty with XMing under Windows.
        I use straight ssh over Fedora.
        Occasionally it would start giving us



        error can't open display localhost


        Reboot of the server would usually fix it but this is stupid.
        Did the above, restarted the service sshd on the server and presto new connections working fine again.






        share|improve this answer






























          up vote
          1
          down vote













          On CentOS 6.5, I suddenly lost remote X-programs access after messing with /etc/hosts.
          Same symptom of empty $DISPLAY variable (no help setting/exporting it manually).



          The 127.0.0.1 entry pointing to the actual hostname is necessary; in fact the order seems to be also relevant (put last & it won't work...)



          [root@poseidon /etc]$ cat hosts
          # Do not remove the following line, or various programs
          # that require network functionality will fail.
          127.0.0.1 localhost.localdomain localhost
          ::1 localhost6.localdomain6 localhost6
          127.0.0.1 poseidon.mycampus.edu poseidon
          1XX.XXX.XXX.208 poseidon.mycampus.edu poseidon


          After fixing this, xeyes, xclock and other X test toys are working again, therefore my needed virt-manager is also back on line.






          share|improve this answer




























            up vote
            1
            down vote













            I just found a nice hiccup in my setup that prevented x forwarding:
            My firewall was blocking all connections from localhost, thus preventing the tunnel to be reached






            share|improve this answer




























              up vote
              1
              down vote













              If you happen to be using Konsole simply switch to another terminal emulator such as Xfce Terminal and try again using root.






              share|improve this answer






























                up vote
                0
                down vote













                open terminal
                $ ssh username@hostname -X



                $ ssh username@hostname -Y

                $ export DISPLAY='IP:0.0'


                export DISPLAY="127.0.0.1:10.0"
                all should work.






                share|improve this answer




























                  up vote
                  0
                  down vote













                  After a lot of frustration I found out that the entry for the hostname of the server in his /etc/host file was incorrect.






                  share|improve this answer




















                    protected by Community Nov 2 at 18:15



                    Thank you for your interest in this question.
                    Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                    Would you like to answer one of these unanswered questions instead?














                    14 Answers
                    14






                    active

                    oldest

                    votes








                    14 Answers
                    14






                    active

                    oldest

                    votes









                    active

                    oldest

                    votes






                    active

                    oldest

                    votes








                    up vote
                    33
                    down vote



                    accepted










                    Check the server's sshd_config (normally /etc/ssh/sshd_config), and make sure the X11Forwarding option is enabled with the line



                    X11Forwarding yes


                    If X11Forwarding is not specified, the default is no on the Debian machines I have available to check.






                    share|improve this answer



















                    • 4




                      I discovered after setting up another Ubuntu VM, that I need to both install xbase-clients and enable X11Forwarding. Update your answer to include both and I'll accept it.
                      – Daryl Spitzer
                      Jul 13 '11 at 19:21






                    • 1




                      Interesting. At least on the new install of 10.04 that I did this morning X11Forwarding was enabled by default. The Ubuntu guys must be messing around with defaults again.
                      – Zoredache
                      Jul 13 '11 at 19:50






                    • 15




                      @DerfK, in my system "X11Forwarding yes" was there already still I am getting error as, (gedit:8381): Gtk-WARNING **: cannot open display: in such cases
                      – A J
                      Oct 6 '15 at 8:30










                    • On Debian you might have to install package xauth, then log again.
                      – comte
                      Aug 7 at 9:40















                    up vote
                    33
                    down vote



                    accepted










                    Check the server's sshd_config (normally /etc/ssh/sshd_config), and make sure the X11Forwarding option is enabled with the line



                    X11Forwarding yes


                    If X11Forwarding is not specified, the default is no on the Debian machines I have available to check.






                    share|improve this answer



















                    • 4




                      I discovered after setting up another Ubuntu VM, that I need to both install xbase-clients and enable X11Forwarding. Update your answer to include both and I'll accept it.
                      – Daryl Spitzer
                      Jul 13 '11 at 19:21






                    • 1




                      Interesting. At least on the new install of 10.04 that I did this morning X11Forwarding was enabled by default. The Ubuntu guys must be messing around with defaults again.
                      – Zoredache
                      Jul 13 '11 at 19:50






                    • 15




                      @DerfK, in my system "X11Forwarding yes" was there already still I am getting error as, (gedit:8381): Gtk-WARNING **: cannot open display: in such cases
                      – A J
                      Oct 6 '15 at 8:30










                    • On Debian you might have to install package xauth, then log again.
                      – comte
                      Aug 7 at 9:40













                    up vote
                    33
                    down vote



                    accepted







                    up vote
                    33
                    down vote



                    accepted






                    Check the server's sshd_config (normally /etc/ssh/sshd_config), and make sure the X11Forwarding option is enabled with the line



                    X11Forwarding yes


                    If X11Forwarding is not specified, the default is no on the Debian machines I have available to check.






                    share|improve this answer














                    Check the server's sshd_config (normally /etc/ssh/sshd_config), and make sure the X11Forwarding option is enabled with the line



                    X11Forwarding yes


                    If X11Forwarding is not specified, the default is no on the Debian machines I have available to check.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Jul 13 '11 at 23:04

























                    answered Jul 13 '11 at 18:54









                    DerfK

                    739610




                    739610








                    • 4




                      I discovered after setting up another Ubuntu VM, that I need to both install xbase-clients and enable X11Forwarding. Update your answer to include both and I'll accept it.
                      – Daryl Spitzer
                      Jul 13 '11 at 19:21






                    • 1




                      Interesting. At least on the new install of 10.04 that I did this morning X11Forwarding was enabled by default. The Ubuntu guys must be messing around with defaults again.
                      – Zoredache
                      Jul 13 '11 at 19:50






                    • 15




                      @DerfK, in my system "X11Forwarding yes" was there already still I am getting error as, (gedit:8381): Gtk-WARNING **: cannot open display: in such cases
                      – A J
                      Oct 6 '15 at 8:30










                    • On Debian you might have to install package xauth, then log again.
                      – comte
                      Aug 7 at 9:40














                    • 4




                      I discovered after setting up another Ubuntu VM, that I need to both install xbase-clients and enable X11Forwarding. Update your answer to include both and I'll accept it.
                      – Daryl Spitzer
                      Jul 13 '11 at 19:21






                    • 1




                      Interesting. At least on the new install of 10.04 that I did this morning X11Forwarding was enabled by default. The Ubuntu guys must be messing around with defaults again.
                      – Zoredache
                      Jul 13 '11 at 19:50






                    • 15




                      @DerfK, in my system "X11Forwarding yes" was there already still I am getting error as, (gedit:8381): Gtk-WARNING **: cannot open display: in such cases
                      – A J
                      Oct 6 '15 at 8:30










                    • On Debian you might have to install package xauth, then log again.
                      – comte
                      Aug 7 at 9:40








                    4




                    4




                    I discovered after setting up another Ubuntu VM, that I need to both install xbase-clients and enable X11Forwarding. Update your answer to include both and I'll accept it.
                    – Daryl Spitzer
                    Jul 13 '11 at 19:21




                    I discovered after setting up another Ubuntu VM, that I need to both install xbase-clients and enable X11Forwarding. Update your answer to include both and I'll accept it.
                    – Daryl Spitzer
                    Jul 13 '11 at 19:21




                    1




                    1




                    Interesting. At least on the new install of 10.04 that I did this morning X11Forwarding was enabled by default. The Ubuntu guys must be messing around with defaults again.
                    – Zoredache
                    Jul 13 '11 at 19:50




                    Interesting. At least on the new install of 10.04 that I did this morning X11Forwarding was enabled by default. The Ubuntu guys must be messing around with defaults again.
                    – Zoredache
                    Jul 13 '11 at 19:50




                    15




                    15




                    @DerfK, in my system "X11Forwarding yes" was there already still I am getting error as, (gedit:8381): Gtk-WARNING **: cannot open display: in such cases
                    – A J
                    Oct 6 '15 at 8:30




                    @DerfK, in my system "X11Forwarding yes" was there already still I am getting error as, (gedit:8381): Gtk-WARNING **: cannot open display: in such cases
                    – A J
                    Oct 6 '15 at 8:30












                    On Debian you might have to install package xauth, then log again.
                    – comte
                    Aug 7 at 9:40




                    On Debian you might have to install package xauth, then log again.
                    – comte
                    Aug 7 at 9:40












                    up vote
                    50
                    down vote













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




                    Answer: You can fix the “cannot open display” error by following the xhost procedure mentioned in this article.



                    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



                    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


                    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.







                    share|improve this answer



















                    • 7




                      +1 for the Note that IP = is the local workstation's IP where you want to get the GUI
                      – PCoder
                      Nov 2 '13 at 10:15






                    • 3




                      For those having similar issues on OS X, also make sure you have XQuartz installed, otherwise none of these fixes help. (OP's question shows he has XQuartz, so this is more a side note to those having similar issues as I was)
                      – Dolan Antenucci
                      May 28 '14 at 21:49






                    • 2




                      Note that running xhost + is very unsecure and should not be used! As Stefan Rogin mentioned, the attacker can then from the host connect to your XSession, read all you type, or even alter the screen you see.
                      – jirislav
                      May 13 at 8:38

















                    up vote
                    50
                    down vote













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




                    Answer: You can fix the “cannot open display” error by following the xhost procedure mentioned in this article.



                    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



                    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


                    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.







                    share|improve this answer



















                    • 7




                      +1 for the Note that IP = is the local workstation's IP where you want to get the GUI
                      – PCoder
                      Nov 2 '13 at 10:15






                    • 3




                      For those having similar issues on OS X, also make sure you have XQuartz installed, otherwise none of these fixes help. (OP's question shows he has XQuartz, so this is more a side note to those having similar issues as I was)
                      – Dolan Antenucci
                      May 28 '14 at 21:49






                    • 2




                      Note that running xhost + is very unsecure and should not be used! As Stefan Rogin mentioned, the attacker can then from the host connect to your XSession, read all you type, or even alter the screen you see.
                      – jirislav
                      May 13 at 8:38















                    up vote
                    50
                    down vote










                    up vote
                    50
                    down vote









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




                    Answer: You can fix the “cannot open display” error by following the xhost procedure mentioned in this article.



                    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



                    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


                    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.







                    share|improve this answer














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




                    Answer: You can fix the “cannot open display” error by following the xhost procedure mentioned in this article.



                    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



                    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


                    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.








                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Aug 3 at 7:26

























                    answered Feb 21 '12 at 8:47









                    harrymc

                    248k10257546




                    248k10257546








                    • 7




                      +1 for the Note that IP = is the local workstation's IP where you want to get the GUI
                      – PCoder
                      Nov 2 '13 at 10:15






                    • 3




                      For those having similar issues on OS X, also make sure you have XQuartz installed, otherwise none of these fixes help. (OP's question shows he has XQuartz, so this is more a side note to those having similar issues as I was)
                      – Dolan Antenucci
                      May 28 '14 at 21:49






                    • 2




                      Note that running xhost + is very unsecure and should not be used! As Stefan Rogin mentioned, the attacker can then from the host connect to your XSession, read all you type, or even alter the screen you see.
                      – jirislav
                      May 13 at 8:38
















                    • 7




                      +1 for the Note that IP = is the local workstation's IP where you want to get the GUI
                      – PCoder
                      Nov 2 '13 at 10:15






                    • 3




                      For those having similar issues on OS X, also make sure you have XQuartz installed, otherwise none of these fixes help. (OP's question shows he has XQuartz, so this is more a side note to those having similar issues as I was)
                      – Dolan Antenucci
                      May 28 '14 at 21:49






                    • 2




                      Note that running xhost + is very unsecure and should not be used! As Stefan Rogin mentioned, the attacker can then from the host connect to your XSession, read all you type, or even alter the screen you see.
                      – jirislav
                      May 13 at 8:38










                    7




                    7




                    +1 for the Note that IP = is the local workstation's IP where you want to get the GUI
                    – PCoder
                    Nov 2 '13 at 10:15




                    +1 for the Note that IP = is the local workstation's IP where you want to get the GUI
                    – PCoder
                    Nov 2 '13 at 10:15




                    3




                    3




                    For those having similar issues on OS X, also make sure you have XQuartz installed, otherwise none of these fixes help. (OP's question shows he has XQuartz, so this is more a side note to those having similar issues as I was)
                    – Dolan Antenucci
                    May 28 '14 at 21:49




                    For those having similar issues on OS X, also make sure you have XQuartz installed, otherwise none of these fixes help. (OP's question shows he has XQuartz, so this is more a side note to those having similar issues as I was)
                    – Dolan Antenucci
                    May 28 '14 at 21:49




                    2




                    2




                    Note that running xhost + is very unsecure and should not be used! As Stefan Rogin mentioned, the attacker can then from the host connect to your XSession, read all you type, or even alter the screen you see.
                    – jirislav
                    May 13 at 8:38






                    Note that running xhost + is very unsecure and should not be used! As Stefan Rogin mentioned, the attacker can then from the host connect to your XSession, read all you type, or even alter the screen you see.
                    – jirislav
                    May 13 at 8:38












                    up vote
                    17
                    down vote













                    I've had this problem when logging into a Ubuntu VM from Mac OS X as well -- it doesn't seem to like 'localhost' in the display variable for some reason. So set the IP manually, as harrymc suggests:



                    export DISPLAY="127.0.0.1:10.0"


                    Then X11 programs should be fine. It doesn't seem like it should be necessary to tell the OS that localhost and 127.0.0.1 are equivalent, but it works, at least.






                    share|improve this answer





















                    • This worked for me. Any idea why localhost wasn't working?
                      – Alex
                      Sep 24 '13 at 4:47






                    • 2




                      BINGO! I've been stuck by that problem for some time... I connected by SSH and couldn't launch Gtk programs (plain X11, like "xeyes", worked however). DISPLAY was correct. Actually, the resolution of "localhost" wasn't! If I set manually DISPLAY=127.0.0.1:10.0, or DISPLAY=::1:10.0 it does work. Editing /etc/hosts seems to have no effect; and DNS is correctly configured ("dig localhost" correclty report both 127.0.0.1 and ::1) So, it seems to be a bug in whatever does DNS resolution for X11 connections in Gtk (gtk? gdk? glib? other?).
                      – Pablo Saratxaga
                      Feb 9 '14 at 11:38








                    • 1




                      On a Debian install for the Beagle Bone Black, /etc/host was not set to readable by anyone but root. This caused the symptoms reported here. Made /etc/hosts readable by all, and it worked fine.
                      – Daniel
                      Mar 6 '16 at 2:00















                    up vote
                    17
                    down vote













                    I've had this problem when logging into a Ubuntu VM from Mac OS X as well -- it doesn't seem to like 'localhost' in the display variable for some reason. So set the IP manually, as harrymc suggests:



                    export DISPLAY="127.0.0.1:10.0"


                    Then X11 programs should be fine. It doesn't seem like it should be necessary to tell the OS that localhost and 127.0.0.1 are equivalent, but it works, at least.






                    share|improve this answer





















                    • This worked for me. Any idea why localhost wasn't working?
                      – Alex
                      Sep 24 '13 at 4:47






                    • 2




                      BINGO! I've been stuck by that problem for some time... I connected by SSH and couldn't launch Gtk programs (plain X11, like "xeyes", worked however). DISPLAY was correct. Actually, the resolution of "localhost" wasn't! If I set manually DISPLAY=127.0.0.1:10.0, or DISPLAY=::1:10.0 it does work. Editing /etc/hosts seems to have no effect; and DNS is correctly configured ("dig localhost" correclty report both 127.0.0.1 and ::1) So, it seems to be a bug in whatever does DNS resolution for X11 connections in Gtk (gtk? gdk? glib? other?).
                      – Pablo Saratxaga
                      Feb 9 '14 at 11:38








                    • 1




                      On a Debian install for the Beagle Bone Black, /etc/host was not set to readable by anyone but root. This caused the symptoms reported here. Made /etc/hosts readable by all, and it worked fine.
                      – Daniel
                      Mar 6 '16 at 2:00













                    up vote
                    17
                    down vote










                    up vote
                    17
                    down vote









                    I've had this problem when logging into a Ubuntu VM from Mac OS X as well -- it doesn't seem to like 'localhost' in the display variable for some reason. So set the IP manually, as harrymc suggests:



                    export DISPLAY="127.0.0.1:10.0"


                    Then X11 programs should be fine. It doesn't seem like it should be necessary to tell the OS that localhost and 127.0.0.1 are equivalent, but it works, at least.






                    share|improve this answer












                    I've had this problem when logging into a Ubuntu VM from Mac OS X as well -- it doesn't seem to like 'localhost' in the display variable for some reason. So set the IP manually, as harrymc suggests:



                    export DISPLAY="127.0.0.1:10.0"


                    Then X11 programs should be fine. It doesn't seem like it should be necessary to tell the OS that localhost and 127.0.0.1 are equivalent, but it works, at least.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jun 29 '12 at 20:44









                    spinup

                    44437




                    44437












                    • This worked for me. Any idea why localhost wasn't working?
                      – Alex
                      Sep 24 '13 at 4:47






                    • 2




                      BINGO! I've been stuck by that problem for some time... I connected by SSH and couldn't launch Gtk programs (plain X11, like "xeyes", worked however). DISPLAY was correct. Actually, the resolution of "localhost" wasn't! If I set manually DISPLAY=127.0.0.1:10.0, or DISPLAY=::1:10.0 it does work. Editing /etc/hosts seems to have no effect; and DNS is correctly configured ("dig localhost" correclty report both 127.0.0.1 and ::1) So, it seems to be a bug in whatever does DNS resolution for X11 connections in Gtk (gtk? gdk? glib? other?).
                      – Pablo Saratxaga
                      Feb 9 '14 at 11:38








                    • 1




                      On a Debian install for the Beagle Bone Black, /etc/host was not set to readable by anyone but root. This caused the symptoms reported here. Made /etc/hosts readable by all, and it worked fine.
                      – Daniel
                      Mar 6 '16 at 2:00


















                    • This worked for me. Any idea why localhost wasn't working?
                      – Alex
                      Sep 24 '13 at 4:47






                    • 2




                      BINGO! I've been stuck by that problem for some time... I connected by SSH and couldn't launch Gtk programs (plain X11, like "xeyes", worked however). DISPLAY was correct. Actually, the resolution of "localhost" wasn't! If I set manually DISPLAY=127.0.0.1:10.0, or DISPLAY=::1:10.0 it does work. Editing /etc/hosts seems to have no effect; and DNS is correctly configured ("dig localhost" correclty report both 127.0.0.1 and ::1) So, it seems to be a bug in whatever does DNS resolution for X11 connections in Gtk (gtk? gdk? glib? other?).
                      – Pablo Saratxaga
                      Feb 9 '14 at 11:38








                    • 1




                      On a Debian install for the Beagle Bone Black, /etc/host was not set to readable by anyone but root. This caused the symptoms reported here. Made /etc/hosts readable by all, and it worked fine.
                      – Daniel
                      Mar 6 '16 at 2:00
















                    This worked for me. Any idea why localhost wasn't working?
                    – Alex
                    Sep 24 '13 at 4:47




                    This worked for me. Any idea why localhost wasn't working?
                    – Alex
                    Sep 24 '13 at 4:47




                    2




                    2




                    BINGO! I've been stuck by that problem for some time... I connected by SSH and couldn't launch Gtk programs (plain X11, like "xeyes", worked however). DISPLAY was correct. Actually, the resolution of "localhost" wasn't! If I set manually DISPLAY=127.0.0.1:10.0, or DISPLAY=::1:10.0 it does work. Editing /etc/hosts seems to have no effect; and DNS is correctly configured ("dig localhost" correclty report both 127.0.0.1 and ::1) So, it seems to be a bug in whatever does DNS resolution for X11 connections in Gtk (gtk? gdk? glib? other?).
                    – Pablo Saratxaga
                    Feb 9 '14 at 11:38






                    BINGO! I've been stuck by that problem for some time... I connected by SSH and couldn't launch Gtk programs (plain X11, like "xeyes", worked however). DISPLAY was correct. Actually, the resolution of "localhost" wasn't! If I set manually DISPLAY=127.0.0.1:10.0, or DISPLAY=::1:10.0 it does work. Editing /etc/hosts seems to have no effect; and DNS is correctly configured ("dig localhost" correclty report both 127.0.0.1 and ::1) So, it seems to be a bug in whatever does DNS resolution for X11 connections in Gtk (gtk? gdk? glib? other?).
                    – Pablo Saratxaga
                    Feb 9 '14 at 11:38






                    1




                    1




                    On a Debian install for the Beagle Bone Black, /etc/host was not set to readable by anyone but root. This caused the symptoms reported here. Made /etc/hosts readable by all, and it worked fine.
                    – Daniel
                    Mar 6 '16 at 2:00




                    On a Debian install for the Beagle Bone Black, /etc/host was not set to readable by anyone but root. This caused the symptoms reported here. Made /etc/hosts readable by all, and it worked fine.
                    – Daniel
                    Mar 6 '16 at 2:00










                    up vote
                    13
                    down vote













                    I had this problem with my CentOS KVM server, I was missing the "xauth" program.






                    share|improve this answer

















                    • 1




                      This helped me out on my minimal debian installation, thank you very much!
                      – binOr
                      Jan 16 '13 at 9:44















                    up vote
                    13
                    down vote













                    I had this problem with my CentOS KVM server, I was missing the "xauth" program.






                    share|improve this answer

















                    • 1




                      This helped me out on my minimal debian installation, thank you very much!
                      – binOr
                      Jan 16 '13 at 9:44













                    up vote
                    13
                    down vote










                    up vote
                    13
                    down vote









                    I had this problem with my CentOS KVM server, I was missing the "xauth" program.






                    share|improve this answer












                    I had this problem with my CentOS KVM server, I was missing the "xauth" program.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Oct 22 '12 at 7:59









                    Joril

                    1,56912129




                    1,56912129








                    • 1




                      This helped me out on my minimal debian installation, thank you very much!
                      – binOr
                      Jan 16 '13 at 9:44














                    • 1




                      This helped me out on my minimal debian installation, thank you very much!
                      – binOr
                      Jan 16 '13 at 9:44








                    1




                    1




                    This helped me out on my minimal debian installation, thank you very much!
                    – binOr
                    Jan 16 '13 at 9:44




                    This helped me out on my minimal debian installation, thank you very much!
                    – binOr
                    Jan 16 '13 at 9:44










                    up vote
                    9
                    down vote













                    If you have this problem after some time when running with -X arg. or just ForwardX11 in /etc/ssh/ssh_config, then run $ ssh username@hostname -Y, to enable trusted X11 forwarding, don't know the exact cause but I'm guessing with -X some features expire after some time, probably to increase security.



                    Here is what I found online :




                    If you use ssh -X remotemachine the remote machine is treated as an
                    untrusted client. So your local client sends a command to the remote
                    machine and receives the graphical output. If your command violates
                    some security settings you'll receive an error instead.



                    But if you use ssh -Y remotemachine the remote machine is treated as
                    trusted client. This last option can open security problems. Because
                    other graphical (X11) client could sniff data from the remote machine
                    (make screenshots, do keylogging and other nasty stuff) and it is even
                    possible to alter those data.



                    If you want to know more about those things I suggest reading the
                    Xsecurity manpage or the X Security extension spec. Furthermore you
                    can check the options ForwardX11 and ForwardX11Trusted in your
                    /etc/ssh/ssh_config.




                    sources:




                    • what is the difference between ssh -Y and ssh -X

                    • cygwin/X warning: could not open X display






                    share|improve this answer



























                      up vote
                      9
                      down vote













                      If you have this problem after some time when running with -X arg. or just ForwardX11 in /etc/ssh/ssh_config, then run $ ssh username@hostname -Y, to enable trusted X11 forwarding, don't know the exact cause but I'm guessing with -X some features expire after some time, probably to increase security.



                      Here is what I found online :




                      If you use ssh -X remotemachine the remote machine is treated as an
                      untrusted client. So your local client sends a command to the remote
                      machine and receives the graphical output. If your command violates
                      some security settings you'll receive an error instead.



                      But if you use ssh -Y remotemachine the remote machine is treated as
                      trusted client. This last option can open security problems. Because
                      other graphical (X11) client could sniff data from the remote machine
                      (make screenshots, do keylogging and other nasty stuff) and it is even
                      possible to alter those data.



                      If you want to know more about those things I suggest reading the
                      Xsecurity manpage or the X Security extension spec. Furthermore you
                      can check the options ForwardX11 and ForwardX11Trusted in your
                      /etc/ssh/ssh_config.




                      sources:




                      • what is the difference between ssh -Y and ssh -X

                      • cygwin/X warning: could not open X display






                      share|improve this answer

























                        up vote
                        9
                        down vote










                        up vote
                        9
                        down vote









                        If you have this problem after some time when running with -X arg. or just ForwardX11 in /etc/ssh/ssh_config, then run $ ssh username@hostname -Y, to enable trusted X11 forwarding, don't know the exact cause but I'm guessing with -X some features expire after some time, probably to increase security.



                        Here is what I found online :




                        If you use ssh -X remotemachine the remote machine is treated as an
                        untrusted client. So your local client sends a command to the remote
                        machine and receives the graphical output. If your command violates
                        some security settings you'll receive an error instead.



                        But if you use ssh -Y remotemachine the remote machine is treated as
                        trusted client. This last option can open security problems. Because
                        other graphical (X11) client could sniff data from the remote machine
                        (make screenshots, do keylogging and other nasty stuff) and it is even
                        possible to alter those data.



                        If you want to know more about those things I suggest reading the
                        Xsecurity manpage or the X Security extension spec. Furthermore you
                        can check the options ForwardX11 and ForwardX11Trusted in your
                        /etc/ssh/ssh_config.




                        sources:




                        • what is the difference between ssh -Y and ssh -X

                        • cygwin/X warning: could not open X display






                        share|improve this answer














                        If you have this problem after some time when running with -X arg. or just ForwardX11 in /etc/ssh/ssh_config, then run $ ssh username@hostname -Y, to enable trusted X11 forwarding, don't know the exact cause but I'm guessing with -X some features expire after some time, probably to increase security.



                        Here is what I found online :




                        If you use ssh -X remotemachine the remote machine is treated as an
                        untrusted client. So your local client sends a command to the remote
                        machine and receives the graphical output. If your command violates
                        some security settings you'll receive an error instead.



                        But if you use ssh -Y remotemachine the remote machine is treated as
                        trusted client. This last option can open security problems. Because
                        other graphical (X11) client could sniff data from the remote machine
                        (make screenshots, do keylogging and other nasty stuff) and it is even
                        possible to alter those data.



                        If you want to know more about those things I suggest reading the
                        Xsecurity manpage or the X Security extension spec. Furthermore you
                        can check the options ForwardX11 and ForwardX11Trusted in your
                        /etc/ssh/ssh_config.




                        sources:




                        • what is the difference between ssh -Y and ssh -X

                        • cygwin/X warning: could not open X display







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited May 23 '17 at 12:41









                        Community

                        1




                        1










                        answered Oct 17 '14 at 8:06









                        Stefan Rogin

                        28038




                        28038






















                            up vote
                            4
                            down vote













                            When running UXTERM or XTERM just issue



                            export $DISPLAY 


                            The variable will be there. Then just set it and export it.






                            share|improve this answer



























                              up vote
                              4
                              down vote













                              When running UXTERM or XTERM just issue



                              export $DISPLAY 


                              The variable will be there. Then just set it and export it.






                              share|improve this answer

























                                up vote
                                4
                                down vote










                                up vote
                                4
                                down vote









                                When running UXTERM or XTERM just issue



                                export $DISPLAY 


                                The variable will be there. Then just set it and export it.






                                share|improve this answer














                                When running UXTERM or XTERM just issue



                                export $DISPLAY 


                                The variable will be there. Then just set it and export it.







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited Jul 10 '12 at 21:28









                                slhck

                                158k46434461




                                158k46434461










                                answered Jul 10 '12 at 21:26









                                Oracle2066

                                411




                                411






















                                    up vote
                                    4
                                    down vote













                                    Just Tested On My Mac, Other Systems Might Be OK:




                                    1. Allow clients to connect from any host using xhost+


                                      $ xhost +




                                    2. You should have an environment that support X11 display


                                      [Mac System] Install X11 for mac https://www.xquartz.org/




                                    3. You should let your ssh-server forward x11 display


                                      update /etc/ssh/sshd_config and set X11Forwarding yes, then restart your ssh server




                                    4. You should let your ssh session forward x11 display with -X parameter


                                      $ ssh -X user@ip




                                    5. How to open X11 app in PyCharm?



                                      • open a ssh session that support X11 display(remember to keep this session)

                                      • run echo $DISPLAY in that ssh session

                                      • set DISPLAY environment variable for your PyCharm









                                    share|improve this answer



















                                    • 1




                                      Why is this different or why should it be preferred over any of the other answer? Please explain if you can with a simple edit. You can do it!!
                                      – Pimp Juice IT
                                      Aug 30 '17 at 12:34










                                    • @McDonald's Thanks, updated with more details.
                                      – Color
                                      Sep 4 '17 at 2:58















                                    up vote
                                    4
                                    down vote













                                    Just Tested On My Mac, Other Systems Might Be OK:




                                    1. Allow clients to connect from any host using xhost+


                                      $ xhost +




                                    2. You should have an environment that support X11 display


                                      [Mac System] Install X11 for mac https://www.xquartz.org/




                                    3. You should let your ssh-server forward x11 display


                                      update /etc/ssh/sshd_config and set X11Forwarding yes, then restart your ssh server




                                    4. You should let your ssh session forward x11 display with -X parameter


                                      $ ssh -X user@ip




                                    5. How to open X11 app in PyCharm?



                                      • open a ssh session that support X11 display(remember to keep this session)

                                      • run echo $DISPLAY in that ssh session

                                      • set DISPLAY environment variable for your PyCharm









                                    share|improve this answer



















                                    • 1




                                      Why is this different or why should it be preferred over any of the other answer? Please explain if you can with a simple edit. You can do it!!
                                      – Pimp Juice IT
                                      Aug 30 '17 at 12:34










                                    • @McDonald's Thanks, updated with more details.
                                      – Color
                                      Sep 4 '17 at 2:58













                                    up vote
                                    4
                                    down vote










                                    up vote
                                    4
                                    down vote









                                    Just Tested On My Mac, Other Systems Might Be OK:




                                    1. Allow clients to connect from any host using xhost+


                                      $ xhost +




                                    2. You should have an environment that support X11 display


                                      [Mac System] Install X11 for mac https://www.xquartz.org/




                                    3. You should let your ssh-server forward x11 display


                                      update /etc/ssh/sshd_config and set X11Forwarding yes, then restart your ssh server




                                    4. You should let your ssh session forward x11 display with -X parameter


                                      $ ssh -X user@ip




                                    5. How to open X11 app in PyCharm?



                                      • open a ssh session that support X11 display(remember to keep this session)

                                      • run echo $DISPLAY in that ssh session

                                      • set DISPLAY environment variable for your PyCharm









                                    share|improve this answer














                                    Just Tested On My Mac, Other Systems Might Be OK:




                                    1. Allow clients to connect from any host using xhost+


                                      $ xhost +




                                    2. You should have an environment that support X11 display


                                      [Mac System] Install X11 for mac https://www.xquartz.org/




                                    3. You should let your ssh-server forward x11 display


                                      update /etc/ssh/sshd_config and set X11Forwarding yes, then restart your ssh server




                                    4. You should let your ssh session forward x11 display with -X parameter


                                      $ ssh -X user@ip




                                    5. How to open X11 app in PyCharm?



                                      • open a ssh session that support X11 display(remember to keep this session)

                                      • run echo $DISPLAY in that ssh session

                                      • set DISPLAY environment variable for your PyCharm










                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Feb 5 at 8:16

























                                    answered Aug 30 '17 at 11:36









                                    Color

                                    412




                                    412








                                    • 1




                                      Why is this different or why should it be preferred over any of the other answer? Please explain if you can with a simple edit. You can do it!!
                                      – Pimp Juice IT
                                      Aug 30 '17 at 12:34










                                    • @McDonald's Thanks, updated with more details.
                                      – Color
                                      Sep 4 '17 at 2:58














                                    • 1




                                      Why is this different or why should it be preferred over any of the other answer? Please explain if you can with a simple edit. You can do it!!
                                      – Pimp Juice IT
                                      Aug 30 '17 at 12:34










                                    • @McDonald's Thanks, updated with more details.
                                      – Color
                                      Sep 4 '17 at 2:58








                                    1




                                    1




                                    Why is this different or why should it be preferred over any of the other answer? Please explain if you can with a simple edit. You can do it!!
                                    – Pimp Juice IT
                                    Aug 30 '17 at 12:34




                                    Why is this different or why should it be preferred over any of the other answer? Please explain if you can with a simple edit. You can do it!!
                                    – Pimp Juice IT
                                    Aug 30 '17 at 12:34












                                    @McDonald's Thanks, updated with more details.
                                    – Color
                                    Sep 4 '17 at 2:58




                                    @McDonald's Thanks, updated with more details.
                                    – Color
                                    Sep 4 '17 at 2:58










                                    up vote
                                    2
                                    down vote













                                    I also had this problem with Solaris 10 and found that the listener was not set up.



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





                                    share|improve this answer



























                                      up vote
                                      2
                                      down vote













                                      I also had this problem with Solaris 10 and found that the listener was not set up.



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





                                      share|improve this answer

























                                        up vote
                                        2
                                        down vote










                                        up vote
                                        2
                                        down vote









                                        I also had this problem with Solaris 10 and found that the listener was not set up.



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





                                        share|improve this answer














                                        I also had this problem with Solaris 10 and found that the listener was not set up.



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






                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited Mar 19 '15 at 0:23









                                        G-Man

                                        5,539102155




                                        5,539102155










                                        answered Mar 18 '15 at 22:52









                                        Doug Somers

                                        211




                                        211






















                                            up vote
                                            2
                                            down vote













                                            I had to put in /etc/ssh/sshd_config the following:



                                            X11UseLocalhost no


                                            Rather then setting it "yes". Strange if the default is "NO"
                                            Users using putty with XMing under Windows.
                                            I use straight ssh over Fedora.
                                            Occasionally it would start giving us



                                            error can't open display localhost


                                            Reboot of the server would usually fix it but this is stupid.
                                            Did the above, restarted the service sshd on the server and presto new connections working fine again.






                                            share|improve this answer



























                                              up vote
                                              2
                                              down vote













                                              I had to put in /etc/ssh/sshd_config the following:



                                              X11UseLocalhost no


                                              Rather then setting it "yes". Strange if the default is "NO"
                                              Users using putty with XMing under Windows.
                                              I use straight ssh over Fedora.
                                              Occasionally it would start giving us



                                              error can't open display localhost


                                              Reboot of the server would usually fix it but this is stupid.
                                              Did the above, restarted the service sshd on the server and presto new connections working fine again.






                                              share|improve this answer

























                                                up vote
                                                2
                                                down vote










                                                up vote
                                                2
                                                down vote









                                                I had to put in /etc/ssh/sshd_config the following:



                                                X11UseLocalhost no


                                                Rather then setting it "yes". Strange if the default is "NO"
                                                Users using putty with XMing under Windows.
                                                I use straight ssh over Fedora.
                                                Occasionally it would start giving us



                                                error can't open display localhost


                                                Reboot of the server would usually fix it but this is stupid.
                                                Did the above, restarted the service sshd on the server and presto new connections working fine again.






                                                share|improve this answer














                                                I had to put in /etc/ssh/sshd_config the following:



                                                X11UseLocalhost no


                                                Rather then setting it "yes". Strange if the default is "NO"
                                                Users using putty with XMing under Windows.
                                                I use straight ssh over Fedora.
                                                Occasionally it would start giving us



                                                error can't open display localhost


                                                Reboot of the server would usually fix it but this is stupid.
                                                Did the above, restarted the service sshd on the server and presto new connections working fine again.







                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited Sep 1 '17 at 1:32









                                                Scott

                                                15.4k113789




                                                15.4k113789










                                                answered Sep 1 '17 at 1:17









                                                Luigi

                                                211




                                                211






















                                                    up vote
                                                    1
                                                    down vote













                                                    On CentOS 6.5, I suddenly lost remote X-programs access after messing with /etc/hosts.
                                                    Same symptom of empty $DISPLAY variable (no help setting/exporting it manually).



                                                    The 127.0.0.1 entry pointing to the actual hostname is necessary; in fact the order seems to be also relevant (put last & it won't work...)



                                                    [root@poseidon /etc]$ cat hosts
                                                    # Do not remove the following line, or various programs
                                                    # that require network functionality will fail.
                                                    127.0.0.1 localhost.localdomain localhost
                                                    ::1 localhost6.localdomain6 localhost6
                                                    127.0.0.1 poseidon.mycampus.edu poseidon
                                                    1XX.XXX.XXX.208 poseidon.mycampus.edu poseidon


                                                    After fixing this, xeyes, xclock and other X test toys are working again, therefore my needed virt-manager is also back on line.






                                                    share|improve this answer

























                                                      up vote
                                                      1
                                                      down vote













                                                      On CentOS 6.5, I suddenly lost remote X-programs access after messing with /etc/hosts.
                                                      Same symptom of empty $DISPLAY variable (no help setting/exporting it manually).



                                                      The 127.0.0.1 entry pointing to the actual hostname is necessary; in fact the order seems to be also relevant (put last & it won't work...)



                                                      [root@poseidon /etc]$ cat hosts
                                                      # Do not remove the following line, or various programs
                                                      # that require network functionality will fail.
                                                      127.0.0.1 localhost.localdomain localhost
                                                      ::1 localhost6.localdomain6 localhost6
                                                      127.0.0.1 poseidon.mycampus.edu poseidon
                                                      1XX.XXX.XXX.208 poseidon.mycampus.edu poseidon


                                                      After fixing this, xeyes, xclock and other X test toys are working again, therefore my needed virt-manager is also back on line.






                                                      share|improve this answer























                                                        up vote
                                                        1
                                                        down vote










                                                        up vote
                                                        1
                                                        down vote









                                                        On CentOS 6.5, I suddenly lost remote X-programs access after messing with /etc/hosts.
                                                        Same symptom of empty $DISPLAY variable (no help setting/exporting it manually).



                                                        The 127.0.0.1 entry pointing to the actual hostname is necessary; in fact the order seems to be also relevant (put last & it won't work...)



                                                        [root@poseidon /etc]$ cat hosts
                                                        # Do not remove the following line, or various programs
                                                        # that require network functionality will fail.
                                                        127.0.0.1 localhost.localdomain localhost
                                                        ::1 localhost6.localdomain6 localhost6
                                                        127.0.0.1 poseidon.mycampus.edu poseidon
                                                        1XX.XXX.XXX.208 poseidon.mycampus.edu poseidon


                                                        After fixing this, xeyes, xclock and other X test toys are working again, therefore my needed virt-manager is also back on line.






                                                        share|improve this answer












                                                        On CentOS 6.5, I suddenly lost remote X-programs access after messing with /etc/hosts.
                                                        Same symptom of empty $DISPLAY variable (no help setting/exporting it manually).



                                                        The 127.0.0.1 entry pointing to the actual hostname is necessary; in fact the order seems to be also relevant (put last & it won't work...)



                                                        [root@poseidon /etc]$ cat hosts
                                                        # Do not remove the following line, or various programs
                                                        # that require network functionality will fail.
                                                        127.0.0.1 localhost.localdomain localhost
                                                        ::1 localhost6.localdomain6 localhost6
                                                        127.0.0.1 poseidon.mycampus.edu poseidon
                                                        1XX.XXX.XXX.208 poseidon.mycampus.edu poseidon


                                                        After fixing this, xeyes, xclock and other X test toys are working again, therefore my needed virt-manager is also back on line.







                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered Jul 15 '14 at 15:13









                                                        David Ramirez

                                                        112




                                                        112






















                                                            up vote
                                                            1
                                                            down vote













                                                            I just found a nice hiccup in my setup that prevented x forwarding:
                                                            My firewall was blocking all connections from localhost, thus preventing the tunnel to be reached






                                                            share|improve this answer

























                                                              up vote
                                                              1
                                                              down vote













                                                              I just found a nice hiccup in my setup that prevented x forwarding:
                                                              My firewall was blocking all connections from localhost, thus preventing the tunnel to be reached






                                                              share|improve this answer























                                                                up vote
                                                                1
                                                                down vote










                                                                up vote
                                                                1
                                                                down vote









                                                                I just found a nice hiccup in my setup that prevented x forwarding:
                                                                My firewall was blocking all connections from localhost, thus preventing the tunnel to be reached






                                                                share|improve this answer












                                                                I just found a nice hiccup in my setup that prevented x forwarding:
                                                                My firewall was blocking all connections from localhost, thus preventing the tunnel to be reached







                                                                share|improve this answer












                                                                share|improve this answer



                                                                share|improve this answer










                                                                answered Jun 10 '16 at 11:56









                                                                Pelle

                                                                1413




                                                                1413






















                                                                    up vote
                                                                    1
                                                                    down vote













                                                                    If you happen to be using Konsole simply switch to another terminal emulator such as Xfce Terminal and try again using root.






                                                                    share|improve this answer



























                                                                      up vote
                                                                      1
                                                                      down vote













                                                                      If you happen to be using Konsole simply switch to another terminal emulator such as Xfce Terminal and try again using root.






                                                                      share|improve this answer

























                                                                        up vote
                                                                        1
                                                                        down vote










                                                                        up vote
                                                                        1
                                                                        down vote









                                                                        If you happen to be using Konsole simply switch to another terminal emulator such as Xfce Terminal and try again using root.






                                                                        share|improve this answer














                                                                        If you happen to be using Konsole simply switch to another terminal emulator such as Xfce Terminal and try again using root.







                                                                        share|improve this answer














                                                                        share|improve this answer



                                                                        share|improve this answer








                                                                        edited May 1 '17 at 17:45

























                                                                        answered May 1 '17 at 4:13









                                                                        Oliver

                                                                        1113




                                                                        1113






















                                                                            up vote
                                                                            0
                                                                            down vote













                                                                            open terminal
                                                                            $ ssh username@hostname -X



                                                                            $ ssh username@hostname -Y

                                                                            $ export DISPLAY='IP:0.0'


                                                                            export DISPLAY="127.0.0.1:10.0"
                                                                            all should work.






                                                                            share|improve this answer

























                                                                              up vote
                                                                              0
                                                                              down vote













                                                                              open terminal
                                                                              $ ssh username@hostname -X



                                                                              $ ssh username@hostname -Y

                                                                              $ export DISPLAY='IP:0.0'


                                                                              export DISPLAY="127.0.0.1:10.0"
                                                                              all should work.






                                                                              share|improve this answer























                                                                                up vote
                                                                                0
                                                                                down vote










                                                                                up vote
                                                                                0
                                                                                down vote









                                                                                open terminal
                                                                                $ ssh username@hostname -X



                                                                                $ ssh username@hostname -Y

                                                                                $ export DISPLAY='IP:0.0'


                                                                                export DISPLAY="127.0.0.1:10.0"
                                                                                all should work.






                                                                                share|improve this answer












                                                                                open terminal
                                                                                $ ssh username@hostname -X



                                                                                $ ssh username@hostname -Y

                                                                                $ export DISPLAY='IP:0.0'


                                                                                export DISPLAY="127.0.0.1:10.0"
                                                                                all should work.







                                                                                share|improve this answer












                                                                                share|improve this answer



                                                                                share|improve this answer










                                                                                answered May 30 at 13:40









                                                                                Kenny Gichuhi

                                                                                1




                                                                                1






















                                                                                    up vote
                                                                                    0
                                                                                    down vote













                                                                                    After a lot of frustration I found out that the entry for the hostname of the server in his /etc/host file was incorrect.






                                                                                    share|improve this answer

























                                                                                      up vote
                                                                                      0
                                                                                      down vote













                                                                                      After a lot of frustration I found out that the entry for the hostname of the server in his /etc/host file was incorrect.






                                                                                      share|improve this answer























                                                                                        up vote
                                                                                        0
                                                                                        down vote










                                                                                        up vote
                                                                                        0
                                                                                        down vote









                                                                                        After a lot of frustration I found out that the entry for the hostname of the server in his /etc/host file was incorrect.






                                                                                        share|improve this answer












                                                                                        After a lot of frustration I found out that the entry for the hostname of the server in his /etc/host file was incorrect.







                                                                                        share|improve this answer












                                                                                        share|improve this answer



                                                                                        share|improve this answer










                                                                                        answered Nov 20 at 8:51









                                                                                        iceburn_pt

                                                                                        716




                                                                                        716

















                                                                                            protected by Community Nov 2 at 18:15



                                                                                            Thank you for your interest in this question.
                                                                                            Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                                                                            Would you like to answer one of these unanswered questions instead?



                                                                                            Popular posts from this blog

                                                                                            flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                                                                                            Mangá

                                                                                             ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕