, 1 min read

Invalid MIT-MAGIC-COOKIE-1 key

1. Problem statement: You can no longer start any X applications. You just get something like

$ xclock
Invalid MIT-MAGIC-COOKIE-1 key
Error: Can't open display: :0

You cannot even run

$ xhost +
Invalid MIT-MAGIC-COOKIE-1 key
xhost:  unable to open display ":0"

So, you are stuck.

2. Solution. Copy current X11 cookie to .Xauthority file, like so:

$ cp -p /tmp/serverauth.wBYidy7HBj .Xauthority

The actual serverauth filename varies.

This was documented here: Invalid MIT-MAGIC-COOKIE-1 keyxhost: unable to open display.

Check with

$ xauth list