X11 connection rejected because of wrong authentication.
Problem
After doing a sudo
, I get this error:
X11 connection rejected because of wrong authentication.
Solution
- Be sure the non-root user can get X working. Try running
xterm
. - Run
xauth list
as the non-root user. You should see something like:
machinename/unix:14 MIT-MAGIC-COOKIE-1 058aexd13d0436b3463abd79acd31234
- Run
echo $DISPLAY
to see which number is used for this host. (eglocalhost:14.0
means 14) - Login as root.
sudo -i
- Add the cookie.
auth add machinename/unix:14 MIT-MAGIC-COOKIE-1 058aexd13d0436b3463abd79acd31234