Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
1  
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
2  
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
    
@jcrawfordor You did check the X11Forwarding on the ubuntu one, and that you have xbase-clients installed and that you can start Xapps on the mac on the terminal you're making ssh connection from. (Check that $DISPLAY is set on the terminal you run ssh from. –  Manwe Feb 27 '12 at 8:16
show 1 more comment

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

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

5 Answers

up vote 6 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
    
That was it. I recommend for the benefit of others reading this later that you make your answer more explicit. (Specify the location of sshd_config, and what to change in it.) –  Daryl Spitzer Jul 13 '11 at 19:05
1  
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
add comment

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
2  
+1 for the Note that IP = is the local workstation's IP where you want to get the GUI –  Codera Purpa Nov 2 '13 at 10:15
add comment

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
    
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 at 11:38
add comment

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
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.