If you are using X and starting a GUI application from a terminal emulatur like Konsole, GNOME Terminal, _xterm, urxvt, this annoying string might popup causing some headache.
Usually this is not considered a bug, because the application starts and runs nonetheless, but it might give some troubles when launched by automated tasks though.
Why it happens
This error is bound to the client-server architecture of X: in practice you can start a software in a remote host and watch its GUI in your local machine, but to do that you have to grant this connection using the xhost command.
Also starting a software from your local machine to run in your local X server requires that permission, and that’s what Invalid MIT-MAGIC-COOKIE-1 key remember us.
$ gvim Invalid MIT-MAGIC-COOKIE-1 key
To fix this error just add the local host in the list of allowed host:
$ xhost +local:
To make this change permanent after the next restart you have to apply it into one of your .profile files.
Depending on how your system is configured you can use the .profile or the .bash_profile file.
Having a Bash shell running on my system I edit the ._bash_profile file, adding the command above or just appending it:
$ echo 'xhost +local:' >> ~/.bash_profile
The new setting will be automatically loaded at every login!