Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

cannot open display: localhost:0.0

51 views
Skip to first unread message

Grzegorz Sójka

unread,
Sep 23, 2018, 5:50:04 AM9/23/18
to
Hi there,

I need to allow remote applications to connect to xorg. Since I log in
using lxdm i have tcp_listen=1 in /etc/lxdm/lxdm.conf. Thus Xorg is
running without -nolisten tcp flag. Unfortunately:

$ xhost +localhost; DISPLAY=localhost:0.0 xterm
localhost being added to access control list
xterm: Xt error: Can't open display: localhost:0.0

Any suggestions??

--
Pozdrawiam
Grzesiek

Wysłane z kompa wolnego od wirusów Billa Gatesa.

Étienne Mollier

unread,
Sep 23, 2018, 6:40:04 AM9/23/18
to
On 9/23/18 1:48 PM, Grzegorz Sójka wrote:
> Hi there,
>
> I need to allow remote applications to connect to xorg. Since I log in using lxdm i have tcp_listen=1 in /etc/lxdm/lxdm.conf. Thus Xorg is running without -nolisten tcp flag. Unfortunately:
>
> $ xhost +localhost; DISPLAY=localhost:0.0 xterm
> localhost being added to access control list
> xterm: Xt error: Can't open display: localhost:0.0
>
> Any suggestions??
>

Maybe try:

xhost +LOCAL:
DISPLAY=localhost:0.0 xterm

Kind Regards,
--
Étienne Mollier <etienne...@mailoo.org>

Grzesiek Sójka

unread,
Sep 23, 2018, 8:30:04 AM9/23/18
to
On 9/23/18 10:30 AM, Étienne Mollier wrote:
> On 9/23/18 1:48 PM, Grzegorz Sójka wrote:
>> Hi there,
>>
>> I need to allow remote applications to connect to xorg. Since I log in using lxdm i have tcp_listen=1 in /etc/lxdm/lxdm.conf. Thus Xorg is running without -nolisten tcp flag. Unfortunately:
>>
>> $ xhost +localhost; DISPLAY=localhost:0.0 xterm
>> localhost being added to access control list
>> xterm: Xt error: Can't open display: localhost:0.0
>>
>> Any suggestions??
>>
>
> Maybe try:
>
> xhost +LOCAL:
> DISPLAY=localhost:0.0 xterm

It does not work:

# xhost +LOCAL; DISPLAY=localhost:0.0 xterm
xhost: bad hostname "LOCAL"
xterm: Xt error: Can't open display: localhost:0.0

Please note that I need to connect also from remote hosts. I used
localhost just for testing.

Regards

Anders Andersson

unread,
Sep 23, 2018, 8:30:04 AM9/23/18
to
On Sun, Sep 23, 2018 at 4:24 PM, Grzesiek Sójka <p...@sojka.co> wrote:
> On 9/23/18 10:30 AM, Étienne Mollier wrote:
>>
>> On 9/23/18 1:48 PM, Grzegorz Sójka wrote:
>>>
>>> Hi there,
>>>
>>> I need to allow remote applications to connect to xorg. Since I log in
>>> using lxdm i have tcp_listen=1 in /etc/lxdm/lxdm.conf. Thus Xorg is running
>>> without -nolisten tcp flag. Unfortunately:
>>>
>>> $ xhost +localhost; DISPLAY=localhost:0.0 xterm
>>> localhost being added to access control list
>>> xterm: Xt error: Can't open display: localhost:0.0
>>>
>>> Any suggestions??
>>>
>>
>> Maybe try:
>>
>> xhost +LOCAL:
>> DISPLAY=localhost:0.0 xterm
>
>
> It does not work:
>
> # xhost +LOCAL; DISPLAY=localhost:0.0 xterm
> xhost: bad hostname "LOCAL"
> xterm: Xt error: Can't open display: localhost:0.0

Are you using Wayland? If you're using debian testing you probably use wayland.

Grzesiek Sójka

unread,
Sep 23, 2018, 8:40:04 AM9/23/18
to
Forgot to mention, I use Sid and xfce4. If i'm not wrong xfce does not
support Wayland.

Grzesiek Sójka

unread,
Sep 23, 2018, 9:10:04 AM9/23/18
to
On 9/23/18 12:59 PM, The Wanderer wrote:
> On 2018-09-23 at 10:24, Grzesiek Sójka wrote:
>
>> On 9/23/18 10:30 AM, Étienne Mollier wrote:
>>
>>> On 9/23/18 1:48 PM, Grzegorz Sójka wrote:
>>>
>>>> Hi there,
>>>>
>>>> I need to allow remote applications to connect to xorg. Since I
>>>> log in using lxdm i have tcp_listen=1 in /etc/lxdm/lxdm.conf.
>>>> Thus Xorg is running without -nolisten tcp flag. Unfortunately:
>>>>
>>>> $ xhost +localhost; DISPLAY=localhost:0.0 xterm
>>>> localhost being added to access control list
>>>> xterm: Xt error: Can't open display: localhost:0.0
>>>>
>>>> Any suggestions??
>>>>
>>>
>>> Maybe try:
>>>
>>> xhost +LOCAL:
>>> DISPLAY=localhost:0.0 xterm
>>
>> It does not work:
>>
>> # xhost +LOCAL; DISPLAY=localhost:0.0 xterm
>> xhost: bad hostname "LOCAL"
>
> Did you try with '+LOCAL:' instead of '+LOCAL'?
>
> The colon is important.

$ xhost +LOCAL: ; DISPLAY=localhost:0.0 xterm
non-network local connections being added to access control list
xterm: Xt error: Can't open display: localhost:0.0

Please note that I need to enable remote connections. I use localhost
just for testing.

The Wanderer

unread,
Sep 23, 2018, 9:10:04 AM9/23/18
to
On 2018-09-23 at 10:24, Grzesiek Sójka wrote:

> On 9/23/18 10:30 AM, Étienne Mollier wrote:
>
>> On 9/23/18 1:48 PM, Grzegorz Sójka wrote:
>>
>>> Hi there,
>>>
>>> I need to allow remote applications to connect to xorg. Since I
>>> log in using lxdm i have tcp_listen=1 in /etc/lxdm/lxdm.conf.
>>> Thus Xorg is running without -nolisten tcp flag. Unfortunately:
>>>
>>> $ xhost +localhost; DISPLAY=localhost:0.0 xterm
>>> localhost being added to access control list
>>> xterm: Xt error: Can't open display: localhost:0.0
>>>
>>> Any suggestions??
>>>
>>
>> Maybe try:
>>
>> xhost +LOCAL:
>> DISPLAY=localhost:0.0 xterm
>
> It does not work:
>
> # xhost +LOCAL; DISPLAY=localhost:0.0 xterm
> xhost: bad hostname "LOCAL"

Did you try with '+LOCAL:' instead of '+LOCAL'?

The colon is important.

--
The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man. -- George Bernard Shaw

signature.asc

Étienne Mollier

unread,
Sep 23, 2018, 9:10:04 AM9/23/18
to
On 9/23/18 2:59 PM, The Wanderer wrote:
> On 2018-09-23 at 10:24, Grzesiek Sójka wrote:
> > On 9/23/18 10:30 AM, Étienne Mollier wrote:
> > > Maybe try:
> > >
> > > xhost +LOCAL:
> > > DISPLAY=localhost:0.0 xterm
> >
> > It does not work:
> >
> > # xhost +LOCAL; DISPLAY=localhost:0.0 xterm
> > xhost: bad hostname "LOCAL"
>
> Did you try with '+LOCAL:' instead of '+LOCAL'?
>
> The colon is important.

Indeed, furthermore if you need to do remote X, using X
forwarding through SSH should be preferred and won't require you
using “xhost” or removing “-nolisten” to Xorg parameters:

ssh -YC user@remotehost

Nicolas George

unread,
Sep 23, 2018, 9:20:04 AM9/23/18
to
Étienne Mollier (2018-09-23):
> or removing “-nolisten” to Xorg parameters:

Finally somebody in this thread who payed attention in the last fifteen
years...

Regards,

--
Nicolas George
signature.asc

Grzesiek Sójka

unread,
Sep 23, 2018, 9:20:04 AM9/23/18
to
I do not need encryption since all machines are in the same network
segment. So I prefer not to use ssh.

Étienne Mollier

unread,
Sep 23, 2018, 9:30:04 AM9/23/18
to
On 9/23/18 5:06 PM, Grzesiek Sójka wrote:
> $ xhost +LOCAL: ; DISPLAY=localhost:0.0 xterm
> non-network local connections being added to access control list
> xterm: Xt error: Can't open display: localhost:0.0

Whoops, however the DISPLAY=localhost:0.0 was a typo of mine.
DISPLAY=:0.0 should have been used in that case. Sorry for the
typo.

That is not very useful when doing SSH indeed, but for launching
X applications under another user for instance, when using
“su -”, it is useful sometimes.

Étienne Mollier

unread,
Sep 23, 2018, 9:40:04 AM9/23/18
to
In that case, perhaps you should simply test with remote
clients; I don't recall having seen this local connection work
reliably.

Please consider using X forwarding anyway, it induces good
habits when working in less trusted environment. Furthermore,
I find this way more convenient to set up (I suppose we all have
different tastes, but to me X forwarding is more seamless than
the whole xhost/Xorg/DISPLAY setting dance. :-)

If you are concerned about performances, maybe X11 is not the
protocol you are looking for on remote links; especially
regarding today's applications but that is another story.

Gene Heskett

unread,
Sep 23, 2018, 10:10:04 AM9/23/18
to
On which machine? The target of the ssh login, or this one with the comfy
office chair to sit it?

Thanks Étienne Mollier.

--
Cheers, Gene Heskett
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>

Rob van der Putten

unread,
Sep 23, 2018, 10:40:03 AM9/23/18
to
Hi there


On 23/09/2018 13:48, Grzegorz Sójka wrote:

> I need to allow remote applications to connect to xorg. Since I log in
> using lxdm i have tcp_listen=1 in /etc/lxdm/lxdm.conf. Thus Xorg is
> running without -nolisten tcp flag. Unfortunately:
>
> $ xhost +localhost; DISPLAY=localhost:0.0 xterm
> localhost being added to access control list
> xterm: Xt error: Can't open display: localhost:0.0
>
> Any suggestions??

Did you check port 6000?
root@pc6:~# netstat -anp | grep 6000
tcp 0 0 0.0.0.0:6000 0.0.0.0:* LISTEN 2684/Xorg
tcp6 0 0 :::6000 :::* LISTEN 2684/Xorg


Regards,
Rob

Gene Heskett

unread,
Sep 23, 2018, 11:50:04 AM9/23/18
to
I did the xhost +LOCAL:
ok,

but I am still locked out of using synaptic-pkexec as the UID=1000
=======paste from local konsole, logged in as gene on rock64========
gene@rock64:~$ synaptic-pkexec
==== AUTHENTICATING FOR com.ubuntu.pkexec.synaptic ===
Authentication is required to run the Synaptic Package Manager
Authenticating as: Gene Heskett,na,na,unlisted,genuine old fart (gene)
Password:
polkit-agent-helper-1: error response to PolicyKit daemon:
GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for
cookie
==== AUTHENTICATION FAILED ===
Error executing command as another user: Not authorized
==================================

Why the heck is it looking for a session cookie? I doubt if its talking
about the container of chocolate chunk cookies I have at hand here. :)

Thanks for any enlightenment.

Étienne Mollier

unread,
Sep 23, 2018, 12:00:05 PM9/23/18
to
On 9/23/18 4:00 PM, Gene Heskett wrote:
> On Sunday 23 September 2018 06:30:01 Étienne Mollier wrote:
> > Maybe try:
> >
> > xhost +LOCAL:
> > DISPLAY=localhost:0.0 xterm
>
> On which machine? The target of the ssh login, or this one
> with the comfy office chair to sit it?

That is not clear out of the context indeed. In that very
situation, there is no remote host considered yet. The purpose
was to demonstrate local graphical connection through the TCP
stack, instead of Unix sockets like it is usually done by X
nowadays. Except it that the graphical server is seemingly
reluctant to work in this configuration.


Let's clarify a bit. By convention, “local” will be the
terminal on your desk, and “remote”, the target of the SSH
login. Their use in commands should be replaced by machines' IP
addresses; or name definition in “/etc/hosts” if applicable.

To run remote X application through TCP connections, one had
firstly to ensure the X server was listening to TCP connections;
of course this check was never done, as long as it was a default
behavior. Debian, and most today's distributions, ship by
default with X servers that don't listen to TCP, so that is not
obvious to establish TCP listening. It is highly dependent on
the way X is started (through GDM3, KDM, SDDM, LightDM, startx,
or whatever). For instance, by using startx, I have in my
“/etc/X11/xinit/xserverrc”:

#!/bin/sh
exec /usr/bin/X -nolisten tcp "$@"

As you can see, the option to not listen to TCP connections is
clearly specified. When I happen to need a listening X server,
I don't tamper with my main display, and use another X server
instead, like “Xephyr”, that I launch on display “:1” for
instance.

Secondly, the current session had to be configured to authorize
X client from “remote” host:

local$ xhost +remote

I believe there are ways to do some basic per-user authorization
as well, this is documented in the manual of xhost(1). Far too
often, I saw the easy solution consisting in allowing every one
on the network to tamper with one's X server (big transparent
window in foreground to annoy the neighbour, anyone?), but it
sure does the job:

local$ xhost + # Don't do that!

Last point was to setup properly the environment on the remote
host at the beginning of the session, through the setting of
DISPLAY variable in the environment. Assuming the X server,
started on the local host, opened its display on :1, the setting
should be:

remote$ DISPLAY=local:1
remote$ export DISPLAY
remote$ xterm

You can check the display on your local machine by doing, on a
newly opened shell window:

local$ echo "$DISPLAY"
:1

/Theoretically/, X programs should start properly, and appear on
the screen of the “local” machine. Wayland has been mentioned,
so that may not even work well on desktop environment running on
top of Wayland instead of X11.


X11 forwarding functions differently, as instead of using a
dedicated TCP connection to the X server on the local machine,
the X client running on the remote machine babbles through an
SSH connection instead. That is why it works, even if X doesn't
listen to TCP 6000.

Gene Heskett

unread,
Sep 23, 2018, 12:00:05 PM9/23/18
to
On Sunday 23 September 2018 10:36:01 Rob van der Putten wrote:

Humm, my puzzle for X11Forwarding has even more pieces.

copy/pasted from the konsole logged into the rock64, running stretch

gene@rock64:~$ sudo netstat -anp|grep 6000
[sudo] password for gene:
gene@rock64:~$ sudo netstat -anp|grep 6000
gene@rock64:~$

Nothing returned, did it twice while logged into the rock64 as
UID=1000=gene

What is this telling me?

Thanks, Rob van der Putten.

Grzesiek Sójka

unread,
Sep 23, 2018, 12:10:04 PM9/23/18
to
Bingo! The command gave me empty output. Now -nolisten tcp is the
default Xorg behaviour. Thus, you need to add -listen tcp flag
explicitly. I added:
arg=/usr/bin/X -background vt07 -listen tcp
to /etc/lxdm/lxdm.conf and now it works perfectly.

Rob van der Putten

unread,
Sep 23, 2018, 5:20:03 PM9/23/18
to
Hi there


On 23/09/2018 20:07, Grzesiek Sójka wrote:

> On 9/23/18 2:36 PM, Rob van der Putten wrote:
>>
>> On 23/09/2018 13:48, Grzegorz Sójka wrote:
>>
>>> I need to allow remote applications to connect to xorg. Since I log
>>> in using lxdm i have tcp_listen=1 in /etc/lxdm/lxdm.conf. Thus Xorg
>>> is running without -nolisten tcp flag. Unfortunately:
>>>
>>> $ xhost +localhost; DISPLAY=localhost:0.0 xterm
>>> localhost being added to access control list
>>> xterm: Xt error: Can't open display: localhost:0.0
>>>
>>> Any suggestions??
>>
>> Did you check port 6000?
>> root@pc6:~# netstat -anp | grep 6000
>> tcp   0   0 0.0.0.0:6000   0.0.0.0:*   LISTEN   2684/Xorg
>> tcp6  0   0 :::6000        :::*        LISTEN   2684/Xorg
>
> Bingo! The command gave me empty output.

Always start low level.

> Now -nolisten tcp is the
> default Xorg behaviour. Thus, you need to add -listen tcp flag
> explicitly.

That changed some time ago.

> I added:
> arg=/usr/bin/X -background vt07 -listen tcp
> to /etc/lxdm/lxdm.conf and now it works perfectly.

Sometimes it's in /etc/X11/xdm/Xservers or /etc/X11/xinit/xserverrc
With lightdm it's in /etc/lightdm/lightdm.conf;
xserver-allow-tcp=true


Regards,
Rob

Greg Wooledge

unread,
Sep 24, 2018, 9:40:04 AM9/24/18
to
On Sun, Sep 23, 2018 at 11:51:29AM -0400, Gene Heskett wrote:
> gene@rock64:~$ sudo netstat -anp|grep 6000
> [sudo] password for gene:
> gene@rock64:~$ sudo netstat -anp|grep 6000
> gene@rock64:~$
>
> Nothing returned, did it twice while logged into the rock64 as
> UID=1000=gene
>
> What is this telling me?

That your X server isn't listening to TCP. Which is normal in this
century. That's why we have DISPLAY=:0 instead of DISPLAY=localhost:0.

(Or, your X server isn't running at all. But since you seemed to expect
to see something, I'm guessing that you actually do have X running, so
my first answer is probably what you want.)
0 new messages