Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm able to login to sever using

ssh -X Hostip

but when i run the command xclock it give me this error

Error: Can't open display: localhost:11.0

I check my Display value using


and the result is


And X11 forwarding is set to YES in sshd_config file

X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes

Any advice what I'm missing here?

share|improve this question
Have you tried -Y instead of -X? – Flup Jul 22 '13 at 11:35
Also, make sure you understand the implications of using -Y instead of -X. You may also want to look at xhost. – Michael Kjörling Jul 22 '13 at 11:36
For RedHat/CentOS 7 (at least), you need the xorg-x11-xauth package, as per my answer here: unix.stackexchange.com/questions/138936/… – Mike S Apr 22 at 20:12

Use -Y. From the man page on ssh:

-Y Enables trusted X11 forwarding. Trusted X11 forwardings are not subjected to the X11 SECURITY extension controls.

If you're still having problems though, you can try setting $DISPLAY to your local box's IP:

$ export DISPLAY='<ip_address>:11.0'

It may work to set it as

$ export DISPLAY=''

People seem to have this problem commonly when ssh'ing from Mac OS X. You may also want to set

X11UseLocalhost no

in this case as well.

share|improve this answer
Using XQuartz I was unable to use the -Y flag. "X11 connection rejected because of wrong authentication." – Erik Feb 21 '14 at 4:01
even after trying your other suggestions, I'm unable to open a display. – Erik Feb 21 '14 at 4:04
Neither one of these worked for me either. I needed to install XWindow support in my Centos 7 server (minimal) with: yum groupinstall "X Window System" -y – Mark Edington Dec 29 '15 at 16:19
@MarkEdington this is because RedHat/CentOS require the xorg-x11-xauth package, as per my answer here: unix.stackexchange.com/questions/138936/… – Mike S Apr 22 at 20:11

this worked for me:


X11UseLocalhost yes


X11UseLocalhost no
share|improve this answer
Thanks, Don. that worked for me also. I gave you an upvote. I believe the problem interfering with the default was that the specific machine is xhost enabled. – L. D. James Dec 22 '15 at 0:21

When trying to forward to XQuartz on macOS, I fixed the issue by running the ssh command (ssh -Y in my case) from the XQuartz terminal (opened by right-clicking the XQuartz icon in the dock and clicking Applications > Terminal).

share|improve this answer

Your Answer


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.