When ~/.Xauthority file is broken, one may see this error.

$ xhost Xlib: connection to ":27.0" refused by server Xlib: No protocol specified xhost: unable to open display ":27.0"
To resurrect ~/.Xauthority on SunRay GNOME desktop, one can do...

$ ps -fu $LOGNAME | grep auth myloginid 38135 4992 0 Feb 15 ? 634:12 /opt/SUNWut/lib/Xnewt :27 -nobanner -auth /var/dt/A:27-czaaCc +bs -kb myloginid 19364 44532 0 13:03:24 pts/65 0:00 grep auth $ xauth -if /var/dt/A:27-czaaCc list #ffff##: MIT-MAGIC-COOKIE-1 9acd879ea2a098959a9183988ebc91a2 $ xauth add $(hostname)/unix:27 MIT-MAGIC-COOKIE-1 9acd879ea2a098959a9183988ebc91a2
This was not possible on RedHat Linux gdm because authority file is owned by root and is not world readable.

Read More about [resurrecting .Xauthority file...