11

After updating to 15.10 it's impossible to run graphical apps from terminal:

xxx@xxx:~$ gksudo wireshark
Invalid MIT-MAGIC-COOKIE-1 key
(gksudo:5532): Gtk-WARNING **: cannot open display: :0
xxx@xxx:~$ sudo -H wireshark
[sudo] password for xxx: 
Invalid MIT-MAGIC-COOKIE-1 key
** (wireshark:5535): WARNING **: Could not open X display
Invalid MIT-MAGIC-COOKIE-1 keyFailed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused

(wireshark:5535): Gtk-WARNING **: cannot open display: :0
xxx@xxx:~$ wireshark
Invalid MIT-MAGIC-COOKIE-1 key
** (wireshark:5569): WARNING **: Could not open X display
Invalid MIT-MAGIC-COOKIE-1 keyFailed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused

(wireshark:5569): Gtk-WARNING **: cannot open display: :0
xxx@xxx:~$ gedit
Invalid MIT-MAGIC-COOKIE-1 key
** (gedit:5570): WARNING **: Could not open X display
Invalid MIT-MAGIC-COOKIE-1 keyFailed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused

(gedit:5570): Gtk-WARNING **: cannot open display: :0
xxx@xxx:~$ sudo gedit
Invalid MIT-MAGIC-COOKIE-1 key
** (gedit:5574): WARNING **: Could not open X display
Invalid MIT-MAGIC-COOKIE-1 keyFailed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused

(gedit:5574): Gtk-WARNING **: cannot open display: :0

My little research pointed to gksudo using but it ain't working either. I've also tried some stuff with xauth. What is the problem? Thanks.

  • 1
    Try removing .Xauthority - sudo rm -f ~/.Xauthority and then restarting. – UniversallyUniqueID May 6 '16 at 14:00
  • Nah, same thing. – sssemil May 6 '16 at 14:13
17

As a regular user, run the command xhost +. After that, try running your graphical application again.

This turns off host-based access control on the X server. Here is the relevant information from the man page:

The xhost program is used to add and delete host names or user names to the list allowed to make connections to the X server.

+ Access is granted to everyone, even if they aren't on the list (i.e., access control is turned off).

| improve this answer | |
  • I've had problems where I can open GUI applications from the terminal as root, but not as a regular user. In that case, running xhost + as root allowed me to then start the GUI applications as a regular user. – Craig Otis Jul 18 '19 at 16:25
  • This worked! Thanks! – Muhammad bin Yusrat Apr 2 at 15:43
4

Odd but export DISPLAY=:1 helped. Cheers.

| improve this answer | |
  • 2
    Are you running multiple X displays or something? Default should be :0 – UniversallyUniqueID May 6 '16 at 14:17
  • 2
    exactly the same issue (on 16.04 in my case); unfortunately this doesn't work. – adam.smith May 7 '16 at 11:45
  • Nope, only one. ":0" was always default but something changed after update. – sssemil May 7 '16 at 17:01
  • 1
    In my case, setting DISPLAY to :0 solved it (while :1 did not) – mbello Jan 27 '17 at 12:54
  • In my case, setting DISPLAY to :2 solved it. Just have to keep trying,. – zkytony Dec 30 '18 at 20:25
1

In my case, the same problem found after updating a single package gnome-shell through synaptic-package-manager. Immediately after next login I was not able to access any GUI part of the OS. Did lots of searching, finaly,

when I used apt install gdm3 from recovery mode terminal, I was able to find a login prompt after system boot(Only terminal, not GUI).

After that I tried apt install gnome which installed a whole bunch of components along, once downloads finished, I was able to get my OS in GUI mode.

If you're not getting login prompt itself then try to follow above step in recovery mode. Otherwise try installing Gnome which updates the gdm3 along.

| improve this answer | |
1

Warning: Improper use of xhost can inadvertently give every host on the Internet full access to an X display server.

Generally you shouldn't turn off host-based access control on the X server unless you know what you're doing. Instead you should only allow the things that require access.

Solution:

Execute: xhost +si:localhost:root

The above solution also works for Wayland users executing an elevated XWayland application.

When attempting to run an XWayland application with elevated permissions you may receive the following error:

No protocol specified
Unable to init server: Could not connect: Connection refused
Could not parse arguments: Cannot open display:
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.