2

I'm at a loss, I have followed the guide on https://www.linode.com/docs/applications/remote-desktop/using-vnc-to-operate-a-desktop-on-ubuntu-12-04 to configure my headless server to allow access via vnc. I have not used any ssh forwarding yet but just directly want to connect to the server on port 5901 and I can't, I only get a message saying Connection to host hostname::5901 was closed but I can confirm with ps ax | grep vnc that my server is running:

$ ps ax | grep vnc
21895 ?        S    158:03 Xtightvnc :1 -desktop X -auth /home/semios/.Xauthority -geometry 1024x768 -depth 16 -rfbwait 120000 -rfbauth /home/semios/.vnc/passwd -rfbport 5901 -fp /usr/share/fonts/X11/misc/,/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/75dpi/,/usr/share/fonts/X11/100dpi/ -co /etc/X11/rgb -localhost
22477 pts/5    S+     0:00 grep --color=auto vnc

and with netstat I can confirm that it is listening on port 5901:

$ netstat -an | grep 5901
tcp        0      0 127.0.0.1:5901          0.0.0.0:*               LISTEN 

so what might be wrong here? Also, I can not seem to find the logfile for Xtightvnc which might give me some more information...

If I connect with $ ssh -p 2200 -X user@server and then connect my VNC client to 127.0.0.1:5901 I get the same message Connection to host 127.0.0.1::5901 was closed.

3
  • 1
    Is a firewall on the server active? Can you ssh -X to the server and run the client locally to connect to localhost::5901 ?
    – Anthon
    Commented Jun 9, 2015 at 13:12
  • @Anthon Please see EDIT 1 above saying that, I do not have control over the router from here but I double checked with the sys admin just now, to make sure port 5901 is forwarded properly, just like 2200... I assumed it was as it had worked previously, but who knows... I better double check!
    – stdcerr
    Commented Jun 9, 2015 at 13:18
  • 1
    we have edit history here. There is no need to put in EDIT etc that pollutes the question (and is irrelevant to future readers). Just edit and optionally ping the commenter that you added the info.
    – Anthon
    Commented Jun 9, 2015 at 13:21

1 Answer 1

1

Because you have invoked the VNC server with the -localhost parameter, it is only accepting connections on the localhost interface - as confirmed by the 127.0.0.1:5901 entry in your netstat output (an externally-open interface would read 0.0.0.0:5901). From the Xvnc manpage:

   -localhost
          Only  allow connections from the same machine. Useful if you use
          SSH and want to stop non-SSH connections from any  other  hosts.
          See the guide to using VNC with SSH on the web site.

In this configuration you must tunnel the connection, else it will be refused. To tunnel over SSH, you can do something like:

ssh -p 2200 -L5901:localhost:5901 user@remotehost -Nf

(the -Nf is optional: it just puts the tunnel in the background) and then start your VNC client and point it at the tunnel endpoint: the details will depend on which client you are using, for example

vncviewer localhost:1
3
  • Steeldriver, Thank you for this! I've tried to connect with the tunnel as well, please see my edit above but that didn't seem to work right out of the bat either, but I have to double check NAT for :5901 with the sys admin
    – stdcerr
    Commented Jun 9, 2015 at 13:23
  • @cerr I don't think the format of your tunnel command is correct: please see my edit above Commented Jun 9, 2015 at 13:34
  • That worked Great, Thanks - only I have all fragmented rendering. I opened a new thread, if you have suggestyions, please see: unix.stackexchange.com/questions/208632/… Thanks
    – stdcerr
    Commented Jun 10, 2015 at 5:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .