# another "Invalid MIT-MAGIC-COOKIE-1 key" [Solved]

## reup

hello all,

on kde, I open konsole

```
$ lreup:~$ echo $DISPLAY

:0.0

lreup:~$ su -

lreup ~ # xclock

Xlib: connection to ":0.0" refused by server

Xlib: Invalid MIT-MAGIC-COOKIE-1 key

Error: Can't open display: :0.0

lreup ~ # echo $DISPLAY

:0.0

lreup ~ # hostname

lreup

lreup ~ # echo $HOSTNAME

lreup

```

the only way I can fix this is by issuing xhost +

I tryed xhost +lreup (my hostname), xhost +localhost, and xhost +:0.0 (this one could not work, but I had to try   :Laughing:  )

xhost + remove all security, can someone tell me how I do wrong ? I believe that echo $DISPLAY should return something else than :0.0

----------

## jcornez

The root user does not have authority to open your display.  You can either copy your ~/.Xauthority file to the root user, or as root you can do something like

```
export XAUTHORITY=~username/.Xauthority
```

----------

## reup

all,

I am pretty sure that their must be a way to set this is some .bash file

I believe it is not a normal behavior that every time I su I have to set some export to be able to work

this is something that happen since I disable PAM then try to correct all problem by reinstalling PAM

even on the konsole, if I run a terminal program like mc, I do get the error, just that mc does load, but if I run xhost +, it works the same, without the errors

what would be the best would be a way to set the xhost to accept request from user root on local host

----------

## jcornez

Ah, you can do the export in your .bashrc file for root...  Assuming that this solution works for you.

----------

## reup

jcornez, thanks you, 

it worked well, I set it in my /root/.bashrc, and the problem is gone

----------

