I'm trying to connect from my mac (Xquartz installed) to a ubuntu server. I use the -Y option with ssh. When I ssh to the server and run any graphical application for example xclock, I get the following error

Could not find ':' in DISPLAY: 1
Error: Can't open display: localhost:10.0

X11 forwarding is set in sshd_config

$ grep -i X11Forward /etc/ssh/sshd_config
# Setting X11Forwarding to "yes" permits encrypted X connections.
X11Forwarding yes


$ echo $DISPLAY

Can someone help me in this regard.


I'll give a generic answer here, because other people might be struggling to setup X forwarding on a Mac here. I think in your specific case, try to run ssh from XQuarts instead of running it from the terminal. Also make sure you have XForwarding set on the serverside and restart sshd after adjusting it.

Prerequisites to run X applications on OS-X:

  • You need to have XQuartz installed on the client side (check that it's working for your account by running XQuarts and starting a local terminal)
  • You need to allow XForwarding on your server. Set the X11Forwarding option (most commonly found in /etc/ssh/sshd_config): X11Forwarding yes (don't forget to restart the ssh server after editing the sshd_config file).
  • Your sshd server should be running on the server side.
  • Your firewall (on both ends) should allow for traffic over port 22.

Running X over ssh:

  1. Start a XQuartz terminal by starting XQuartz and pressing +n
  2. In the terminal type: ssh -X [username]@[servername] (you can also use -Y instead of -X)
  3. You should be logged in to your server. Try xeyes for example to have X look back at you.


  • "Connection refused": check your firewall settings (on both ends) and check if the ssh server (sshd) is running on the receiving side.
  • $DISPLAY errors: ssh should be taking care of setting the $DISPLAY variable. If your are running from XQuartz, this means that (for one reason or another) ssh wasn't able to setup a Xforwarded session. Check any errors in your log files (particulary on the server side) and try ssh with verbose output -v or even -vv or -vvv and look for clues). Don't tamper with the $DISPLAY setting yourself, because it's the effect of ssh not being able to establish a tunnel, not the cause.
  • Thanks ! In my case, I did not logout and login for the X to take effect and because of which it was failing. – psteelk Feb 8 '15 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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