Trying to debug and simultaneously trawling Google for a non-trivial version of this issue:
$ xclock
X11 connection rejected because of wrong authentication.
X connection to localhost:10.0 broken (explicit kill or server shutdown).
I finally cracked it. This was from the outset clearly not your usual xauth list and xauth add issue, nor an issue with the hostname though it did look like a potential candidate at some point.
.Xauthority was clearly updated correctly, so I ended up creating a test user, which worked fine, and here is what I eventually found:
$ unset LDR_PRELOAD LDR_PRELOAD64
These two environment variables broke anything X-related. You can even tell the X library uses those variables by setting it to garbage:
$ LDR_PRELOAD=”Tuppence”
$ xclock
exec(): 0509-036 Cannot load program xclock because of the following errors:
0509-150 Dependent module Tuppence could not be loaded.
0509-022 Cannot load module Tuppence.
0509-026 System error: A file or directory in the path name does not exist.
Unesetting, and it all works fine.