title: XQuartz $DISPLAY problems, cannot open xclock locally, cannot ssh -X
body: <p>I am trying to solve a cascading series of bugs that started with me not able to copy to my macOS clipboard from remote ssh and has lead me to realize my X11 situation is seriously messed up. I have read a few other stackoverflow threads and they do not address my particular problems. </p>
  
  <p>First my setup is macOS Mojave 10.14.5. I have xquartz 2.7.11 <a href="https://www.xquartz.org/" rel="nofollow noreferrer">installed from the website</a>. When I run <code>echo $DISPLAY</code> locally (on macOS) I get <code>/private/tmp/com.apple.launchd.waagOnO6Qm/org.macosforge.xquartz:0</code>.</p>
  
  <p>Since I don't know where the error actually is I will list two problems I can identify currently.</p>
  
  <h1>Two problems:</h1>
  
  <ol>
  <li>If I run <code>xclock</code> locally nothing happens inside my terminal. I do notice that an "active" dot appears under the XQuartz dock icon for a second and then disappears. But after this happens my terminal still just hangs at <code>xclock</code> as though it is running. </li>
  <li>If I try to <code>ssh -X remote</code> into a remote machine my terminal is locked out. I cannot keyboard interrupt. I ran this with <code>-vvv</code> to try to debug and I see that it hangs with <code>xauth</code>:</li>
  </ol>
  
  <pre><code>debug2: client_x11_get_proto: /opt/X11/bin/xauth -f /var/folders/jw/ltyk9x9n0_xb61jhdnct27fr0000gn/T//ssh-vcqwT7qh5yk2/xauthfile generate /private/tmp/com.apple.launchd.waagOnO6Qm/org.macosforge.xquartz:0 MIT-MAGIC-COOKIE-1 untrusted timeout 1260 2&gt;/dev/null
  </code></pre>
  
  <h1>Attempts to Solve</h1>
  
  <ol>
  <li>Other related stack threads have suggested reinstalling XQuartz, which I have done, both manually and with Homebrew. I have logged back out and in following reinstallation.</li>
  <li><a href="https://superuser.com/questions/806637/xauth-not-creating-xauthority-file#941244">This thread</a> suggested I solve my <code>xauth</code> problem by deleting <code>.XAuthority</code> file and recreating it. However, when I </li>
  </ol>
  
  <pre><code>xauth generate :0 . trusted 
  </code></pre>
  
  <p>My <code>XQuartz</code> pops up a window saying <code>XQuartz quit unexpectedly</code> which I can provide the Report for if it helps. Then in the terminal it says 
  <code>xauth: (argv):1:  unable to open display ":0".</code> Also I'm not sure this is the problem anyway because my <code>.XAuthority</code> file already contained an entry that it looks like this is trying to produce:
  <code>$HOST/unix:0  MIT-MAGIC-COOKIE-1  db7738324ca3662767b20b97b4a68680</code>
  Though it is concerning that running <code>xauth</code> is causing my <code>xquartz</code> to repeatedly quit unexpectedly (this dialog box is appearing multiple times).</p>
  
  <p>This has been very frustrating to debug because I am not sure where the problem is, with <code>xauth</code> or <code>xquartz</code> somehow even though it is newly installed. Further, existing StackOverflow threads I have found detail the problem only with <code>ssh -X</code> but clearly I'm having problems locally, given that I can't even run <code>xclock</code>. </p>
  
  <p>Any help is greatly appreciated.</p>