Start XQuartz automatically on X11 app launch

Solution 1:

I was having the same problem. Quitting XQuartz and deleting ~/.Xauthority resolved the issue for me. I got the idea to do this from the Mountain Lion, Xquartz, and (lost) autostart thread in the Apple Mailing List. Other suggestions from that thread include:

  • Logging out and then back in after installing XQuartz.
  • Ensuring that the $DISPLAY variable is being set by by launchd and not clobbered by your shell scripts (see http://xquartz.macosforge.org/trac/wiki/X11-UsersFAQ#sshXforwardingdebugging)

Solution 2:

I don't have to launch xQuartz, I just use Terminal and ssh -Y user@IP. Then X emulation appears to be available as I can launch X windows from the server.

Solution 3:

I know this is an old question, but it's still occasionally relevant - so here's a different (but likely obscure) scenario that can lead to this.

Because zsh isn't always installed on (non Mac) systems, I've been in the habit of leaving bash as my default shell with an entry in .bash_profile which does exec zsh -l if zsh exists. This turned out to be the cause of XQuartz not auto launching in my case (even though I could manually start it from the command line) - likely because $DISPLAY wasn't set correctly in bash.

Once I switched my Mac shell to zsh, XQuartz will now auto launch when I run an X11 app locally or remotely.