Changing the hostname while X is running causes any entries in ~/.Xauthority to be rendered invalid. This will cause X clients to lose access to the display.
This seems to be a common/known issue throughout the internet, but I wanted to open a bug to see if anyone has an idea for how to make this work better.
% xauth list
naomi/unix:0 MIT-MAGIC-COOKIE-1 3abfa887b6a166c2d35530217bed7f86
% sudo hostname naomi2
No protocol specified
Error: couldn't open display :0
% sudo hostname naomi
Running synchronized to the vertical refresh. The framerate should be
approximately the same as the monitor refresh rate.
As we spoke on IRC, closing this one.