1

I have a Debian 10 system with a desktop environment installed and running. When I open a terminal and try to run any GUI application , such as gedit, from the command line, it fails to open with the following messages:

# gedit
Unable to init server: Could not connect: Connection refused

(gedit:3575): Gtk-WARNING **: 12:26:48.311: cannot open display: 

This happens with any user, not just root.

I have tried running the following based on suggestions to no avail:

 export DISPLAY=:0
 export DISPLAY=:1
 export DISPLAY=:2
 export DISPLAY=:3
 export DISPLAY=:4
 export DISPLAY=:5
 export DISPLAY=:6




xhost +

Anyone have any idea whats wrong here?

EDIT:

If I run export DISPLAY=:0 as a normal user, then the normal user can run GUI programs from the command line, however whenever I try the same with root it fails with the messages:

No protocol specified
Unable to init server: Could not connect: Connection refused
No protocol specified
Unable to init server: Could not connect: Connection refused
No protocol specified
Unable to init server: Could not connect: Connection refused

(gedit:3609): Gtk-WARNING **: 12:33:16.307: cannot open display: :0
0

The display belongs to the user. So, if you want to allow another user to draw on it (think of it as a printer) you have to grant permissions.

There are many ways to do that, but the simplest is probably to open the graphic terminal and run:

$ xhost +

That will allow connections to the server from other users.

Then, from the other user you can run:

$ export DISPLAY=:0

It could be another display, such as :1 ...

If you want to avoid those two steps, you can ssh into the other user, with the -X flag (that forwards the display):

$ ssh -X -l other_user localhost
| improve this answer | |
  • I have already tried xhost + to no avail. – another_stack_user999 Oct 31 '19 at 14:19
  • You have to do both things, in two different places. The xhost + as the normal user and then, from the other user's shell the export DISPLAY.... To check, just run xeyes. To be sure of the display you want to export for the second user, you can do echo $DISPLAY from the normal user's shell. – Eduardo Trápani Oct 31 '19 at 14:36

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.