Fix: cannot open display: :0.0

Off late I noticed X applications on my Gentoo installation failing to launch in gnome sessions unless launched within first few seconds. It didn’t seem easily reproducible so it took me a few xdm and os restarts to nail the actual problem.

NetworkManager changes the hostname after connecting to wireless network. However, it doesn’t update xauth with the new hostname, which means .Xauthority file is no longer valid once the hostname is changed, and attempts to launch applications fail with ‘no protocol specified/cannot open display’ messages.

In my case, i believe, ‘etc-update’ was the culprit. Fix is to update /etc/conf.d/hostname with the desired hostname, which is apparently honored by NetworkManager. Once HOSTNAME is set in the conf-file, and OS is rebooted, ‘xhost list’ can be used to validate the .Xauthority contents and hostname can be matched. X applications should start without any trouble.

About this entry