I'm able to login to the server using:

ssh -X Hostip

but when I run the command xclock it gives me this error:

Error: Can't open display: localhost:11.0

I checked 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

Do you have any advice what I'm missing here?

  • 3
    Have you tried -Y instead of -X?
    – Flup
    Commented Jul 22, 2013 at 11:35
  • 2
    Also, make sure you understand the implications of using -Y instead of -X. You may also want to look at xhost.
    – user
    Commented Jul 22, 2013 at 11:36
  • 1
    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
    Commented Apr 22, 2016 at 20:12

7 Answers 7


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.

  • 1
    Using XQuartz I was unable to use the -Y flag. "X11 connection rejected because of wrong authentication."
    – Erik
    Commented Feb 21, 2014 at 4:01
  • 6
    even after trying your other suggestions, I'm unable to open a display.
    – Erik
    Commented Feb 21, 2014 at 4:04
  • 2
    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 Commented Dec 29, 2015 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
    Commented Apr 22, 2016 at 20:11

this worked for me:


X11UseLocalhost yes


X11UseLocalhost no
  • 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. Commented Dec 22, 2015 at 0:21
  • 13
    on guest? host? which configuration file? thx to complete your answer Commented Jul 20, 2016 at 8:22
  • I made it to work by dropping the settings to /etc/ssh/sshd_config.
    – llinfeng
    Commented Apr 29, 2019 at 16:22
  • focal: Bad configuration option: x11uselocalhost
    – woodz
    Commented Feb 19, 2021 at 17:38

Credit to https://unix.stackexchange.com/a/12772/61349 for their diagnostic instructions.

Ensure you're ssh client is requesting X11 Forwarding with the -v flag

ssh example.com -X -v

And look for thespecific message:

debug1: Requesting X11 forwarding with authentication spoofing.

Another telltail problem sign is the lack of the DISPLAY environment variable beign set for you. If its blank/unset, there is something wrong. At least according to the same post credited above, these variables are set for you automatically.

I was using an SSH Control Master my ssh connections like so:

Host <hostname>
    ControlMaster auto
    ControlPath ~/.ssh/control/%r@%h:%p
    ControlPersist 10m

My earlier ssh connection did not request X11Firwarding, therefore future ssh call's options weren't being used. So for me,

ssh -X was just being ignored altogether

If you aren't seeing "Requesting X11 Forwarding", but you do see the muxer reusing sessions;

debug1: auto-mux: Trying existing master
debug1: mux_client_request_session: master session id: 10

Then you need to exit your current ControlMaster for that connection and reconnect with the -X/-Y flag.

To Stop your ControlMaster

ssh -O check <hostname>

Master running (pid=2758)

(This will exit all active connections using the ControlMaster)

ssh -O exit <hostname>

Exit request sent.
  • what should I do if I see debug1: Requesting X11 forwarding with authentication spoofing then?
    – Esther
    Commented May 9, 2022 at 18:18

What fixed this for me is simply installing xauth, once done it worked like a charm!


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).

  • 1
    this worked for me
    – dli
    Commented Sep 12, 2019 at 21:10
  • The only way that worked for me too (instead of using iterm2). So this means it's a problem on the client (MacOS).
    – Phlogi
    Commented Oct 10, 2021 at 12:55

Problem got fixed by installing "x11-server-utils" and reloading both sshd and my ssh session.


I faced similar problem - i was working on a remote server where i had to work with interactive plots and none of the above mentioned solutions worked for me.

I was using Ubuntu bash on Windows 10 and in the end installing Xming software (http://www.straightrunning.com/XmingNotes/) on Windows. There might be some configurations needed but I was finally able to work with plots on remote server. Just install and launch it (you can see its icon on the bottom tray), and run your graphical application again on the remote server (using the ssh session). Hope it helps!

  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Feb 13, 2022 at 20:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .