# Can't open display on remote system



## graemeg (Feb 23, 2016)

Hi,

I have my workstation running FreeBSD since 9.x and upgraded it over the years to 10.1. It works well. I just installed FreeBSD 10.2 on an old laptop. On the laptop I can do `export DISPLAY=192.168.0.2:0; xcalc` and XCalc will appear on my workstation screen. But I can't do the reverse. Any ideas why?


```
[~]$ export DISPLAY=192.168.0.31:0
[~]$ xcalc
Error: Can't open display: 192.168.0.31:0
```

I ran `xhost +` on my laptop, and it said "access control disabled", but it makes no difference. The workstation still can't open the laptop display.

Any help would be much appreciated.

Regards,
  G.


----------



## SirDice (Feb 23, 2016)

The laptop would have to have Xorg listening on a network port. This isn't by default. You probably modified this on your workstation a long time ago and forgot about it.


----------



## graemeg (Feb 23, 2016)

Thanks SirDice - I believe you are correct. Using `netstat -naf inet | grep 6000` on both systems, I can see my workstation listens on port 6000, but the laptop doesn't.

You wouldn't happen to know what I need to change in FreeBSD on the laptop to enable Xorg listening on a netwok port too? I did some internet searching and only get loads of Linux references, and the settings files don't match up with FreeBSD.


----------



## Juha Nurmela (Feb 23, 2016)

You have to describe how you start X.  There are many possibles places.

Do you need networked X constantly or rarely? Check Xnest or Xephyr, x11-servers/xorg-nestserver and x11-servers/xephyr. I find it convenient to just type `Xnest :1 -listen tcp` in the rare occasion.

Juha


----------



## graemeg (Feb 23, 2016)

On my workstation and laptop, my systems boot to the console login screen. I then log in with my user and run `startx -- -dpi 96`.

Using the command above, my workstation listens to port 6000 without me specifying the `-listen tcp` parameter. So where does it get it's TCP listening setting from? Either way, I'll try the `-listen` parameter on my laptop and see if `netstat` reports port 6000.  [few seconds later]  Nope, just started my X11 on my laptop using `-listen_tcp` and also tried `-listen tcp`, netstat still reports nothing is listen on port 6000 and I could get xcalc to display from my workstation onto my laptop.

What I'm trying to achieve is use my laptop as a second screen for my workstation, using Xdmx (x11-servers/xorg-dmx)... as described in this IBM article.
http://www.ibm.com/developerworks/library/os-mltihed/index.html

I can get Xdmx to work using a slightly different method... SSH with X11 forwarding enabled, but that is more effort than the IBM article.


----------



## hukadan (Feb 23, 2016)

graemeg said:


> Using the command above, my workstation listens to port 6000 without me specifying the  -listen tcp parameter. So where does it get it's TCP listening setting from?



Could you give the version of x11-servers/xorg-server on your workstation ? Depending on your version, the Xorg server may or may not listen by default (see here for more information).


----------



## Juha Nurmela (Feb 23, 2016)

`startx -- -dpi 96 -listen tcp` ought to do it, and you should be able to see it in `ps axww | grep X`. Clear any stale /tmp/.X0-lock in case it picked up $DISPLAY as :1 (port 6001).

Juha


----------



## graemeg (Feb 23, 2016)

hukadan : Here is a snippet from the Xorg log stating the version on my workstation.


```
X.Org X Server 1.14.7
Release Date: 2014-06-05
[257790.744] X Protocol Version 11, Revision 0
[257790.744] Build Operating System: FreeBSD 10.0-RELEASE-p9 amd64
[257790.744] Current Operating System: FreeBSD graeme-desktop 10.1-RELEASE-p26 FreeBSD 10.1-RELEASE-p26 #0: Wed Jan 13 20:59:29 UTC 2016  root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64
[257790.745] Build Date: 21 January 2015  05:52:30AM
```

The laptop shows Xorg v1.17.4


----------



## graemeg (Feb 23, 2016)

Juha Nurmela said:


> `startx -- -dpi 96 -listen tcp` ought to do it, and you should be able to see it in `ps axww | grep X`. Clear any stale /tmp/.X0-lock in case it picked up $DISPLAY as :1 (port 6001).



Thanks Juha Nurmela - that seems to have done the trick. There was stale lock files in /tmp/. After clearing them and starting the X11 server again, I can now display content on my laptop, from my workstation.

Still not sure why my workstation's Xorg automatically listens for port 6000, but as others suggested, maybe it is because it is an older version that had it as a default setting. No worries though, at least I got my laptop Xorg working correctly now.

Many thanks to everybody that helped with this.


----------



## hukadan (Feb 23, 2016)

graemeg said:


> maybe it is because it is an older version that had it as a default setting.


Yep. That's it. The `-nolisten tcp` is default option starting from 1.17. You should consider updating your system by the way. Given your Xorg server version, you haven't done it for a while.


----------



## protocelt (Feb 23, 2016)

graemeg said:


> Still not sure why my workstation's Xorg automatically listens for port 6000, but as others suggested, maybe it is because it is an older version that had it as a default setting.


 Correct, Xserver 1.16 and older were automatically configured by default to listen on TCP port 6000(-listen tcp). This changed in version 1.17 (-nolisten tcp)


----------



## graemeg (Feb 23, 2016)

hukadan said:


> You should consider updating your system by the way. Given your Xorg server version, you haven't done it for a while.


Indeed, looking at the date of the build I see what you mean. I try and practice the philosophy of "if it ain't broken, don't "fix" it".   Plus I really haven't master updating all installed ports packages - I'll need to read the handbook some more. I use this workstation daily, and can't afford it to go down for a day.


----------



## Juha Nurmela (Feb 24, 2016)

Reboot clears the locks, unless rcvar _clear_tmp_X_ has been overridden.

There is an example in xauth(1) how to shuffle authorization cookies around with ssh.
If it goes wrong, the error message is friendly _No protocol specified_. 

Juha


----------

