This question already has an answer here:

I am trying to find a way to su to a user and run a graphical applications (My goal is to run another instance of google drive but for now - just running any application would be fine). I am basically looking for an equivalent of xhost + from Linux.

Currently when I try running iTerm for example as a different user I get:

FAILED TO establish the default connection to the WindowServer

So how can I accomplish this?

marked as duplicate by Ian C. May 20 '14 at 21:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • What's the full command you're running that leads to that error message? – Ian C. May 20 '14 at 20:33
  • Thanks, for example: sudo su - differentuser -c "/Applications/iTerm.app/Contents/MacOS/iTerm" Password: ... _RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL. – Gil May 20 '14 at 20:40
  • See the duplicate question for the syntax. You want to use target /Applications/iTerm.app/Contents/MacOS/iTerm for the sudo call to start iTerm as another user. – Ian C. May 20 '14 at 21:09

Browse other questions tagged .