Score:0

Connection to VNC server failed: Connection refused; VNC server closed connection and X server already running on display :1

cn flag
s.k

I've set up a VNC server along with xfce4 on a remote machine following this tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-20-04

in short, on the server:

$ apt update && apt install xfce4 xfce4-goodies tightvncserver

after what I started a VNC instance as simple as follows (I've set up a password when prompted):

$ tightvncserver -localhost -geometry 1600x1280


New 'X' desktop is server.domain.org:1

Starting applications specified in /home/userroot/.vnc/xstartup
Log file is /home/userroot/.vnc/server.domain.org:1.log

here's the xstartup file content in ~/.vnc:

#!/bin/sh
set -xv

xrdb $HOME/.Xresources
#xsetroot -solid grey
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
# Fix to make GNOME work
#export XKL_XMODMAP_DISABLE=1
#/etc/X11/Xsession
/usr/bin/startxfce4 &

I also tried to add these two lines in this xstartup file:

unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS

as documented here: https://ubuntuforums.org/showthread.php?t=2442905&s=1a71305ce4f7a8e7360357cf0dbc074c&p=13955725#post13955725
but that doesn't change anything.

Here's the content of the log file: server.domain.org:1.log once the VNC instance has started:

03/07/21 13:33:13 Xvnc version TightVNC-1.3.10
03/07/21 13:33:13 Copyright (C) 2000-2009 TightVNC Group
03/07/21 13:33:13 Copyright (C) 1999 AT&T Laboratories Cambridge
03/07/21 13:33:13 All Rights Reserved.
03/07/21 13:33:13 See http://www.tightvnc.com/ for information on TightVNC
03/07/21 13:33:13 Desktop name 'X' (server.domain.org:1)
03/07/21 13:33:13 Protocol versions supported: 3.3, 3.7, 3.8, 3.7t, 3.8t
03/07/21 13:33:13 Listening for VNC connections on TCP port 5901
Font directory '/usr/share/fonts/X11/75dpi/' not found - ignoring
Font directory '/usr/share/fonts/X11/100dpi/' not found - ignoring

xrdb $HOME/.Xresources
+ xrdb /home/userroot/.Xresources
xrdb: No such file or directory
xrdb: can't open file '/home/userroot/.Xresources'
#xsetroot -solid grey
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
# Fix to make GNOME work
#export XKL_XMODMAP_DISABLE=1
#/etc/X11/Xsession
/usr/bin/startxfce4 &

+ /usr/bin/startxfce4
/usr/bin/startxfce4: X server already running on display :1
Xlib:  extension "RANDR" missing on display ":1".
gpg-agent[23223]: WARNING: "--write-env-file" is an obsolete option - it has no effect
gpg-agent: a gpg-agent is already running - not starting a new one

(xfce4-session:23216): xfce4-session-WARNING **: 13:33:14.479: gpg-agent returned no PID in the variables
(xfce4-session:23216): xfce4-session-WARNING **: 13:33:14.480: xfsm_manager_load_session: Something wrong with /home/userroot/.cache/sessions/xfce4-session-server.domain.org:1, Does it exist? Permissions issue?
Xlib:  extension "RANDR" missing on display ":1.0".
(xfwm4:23226): xfwm4-WARNING **: 13:33:14.499: The display does not support the XRender extension.
(xfwm4:23226): xfwm4-WARNING **: 13:33:14.499: The display does not support the XRandr extension.
(xfwm4:23226): xfwm4-WARNING **: 13:33:14.499: The display does not support the XComposite extension.
(xfwm4:23226): xfwm4-WARNING **: 13:33:14.499: The display does not support the XDamage extension.
(xfwm4:23226): xfwm4-WARNING **: 13:33:14.499: The display does not support the XFixes extension.
(xfwm4:23226): xfwm4-WARNING **: 13:33:14.499: Compositing manager disabled.

Xlib:  extension "RANDR" missing on display ":1.0".
Xlib:  extension "RANDR" missing on display ":1.0".
Xlib:  extension "RANDR" missing on display ":1.0".
Xlib:  extension "RANDR" missing on display ":1.0".
xfwm4-Message: 13:33:14.537: Unsupported keyboard modifier '<Super>Tab'

(xfwm4:23226): xfwm4-WARNING **: 13:33:14.538: Cannot find visual format on screen 0
Xlib:  extension "RANDR" missing on display ":1.0".
(xfsettingsd:23231): xfsettingsd-CRITICAL **: 13:33:14.555: No RANDR extension found in display :1.0. Display settings won't be applied.
Xlib:  extension "XInputExtension" missing on display ":1.0".
(xfsettingsd:23231): xfsettingsd-CRITICAL **: 13:33:14.555: XI is not present.
(xfsettingsd:23231): xfsettingsd-CRITICAL **: 13:33:14.555: Failed to initialize the Xkb extension.
(xfsettingsd:23231): xfsettingsd-CRITICAL **: 13:33:14.556: Failed to initialize the Accessibility extension.
(Thunar:23233): Gtk-WARNING **: 13:33:14.557: Unable to locate theme engine in module_path: "pixmap",
  (plenty of time the previous line)
(xfwm4:23226): Gtk-WARNING **: 13:33:14.560: Unable to locate theme engine in module_path: "pixmap",
(xfdesktop:23235): Gtk-WARNING **: 13:33:14.561: Unable to locate theme engine in module_path: "pixmap",
(xfwm4:23226): Gtk-WARNING **: 13:33:14.561: Unable to locate theme engine in module_path: "pixmap",
(xfwm4:23226): Gtk-WARNING **: 13:33:14.561: Unable to locate theme engine in module_path: "pixmap",
(xfdesktop:23235): Gtk-WARNING **: 13:33:14.561: Unable to locate theme engine in module_path: "pixmap",
(xfdesktop:23235): Gtk-WARNING **: 13:33:14.561: Unable to locate theme engine in module_path: "pixmap",
(xfwm4:23226): Gtk-WARNING **: 13:33:14.562: Unable to locate theme engine in module_path: "pixmap",
(xfwm4:23226): Gtk-WARNING **: 13:33:14.562: Unable to locate theme engine in module_path: "pixmap",
(xfdesktop:23235): Gtk-WARNING **: 13:33:14.562: Unable to locate theme engine in module_path: "pixmap",
(xfdesktop:23235): Gtk-WARNING **: 13:33:14.562: Unable to locate theme engine in module_path: "pixmap",
(xfce4-session:23216): Gtk-WARNING **: 13:33:14.564: Unable to locate theme engine in module_path: "pixmap",
  (plenty of time the previous line)
vmware-user: could not open /proc/fs/vmblock/dev
(xfsettingsd:23231): Gtk-WARNING **: 13:33:14.571: Unable to locate theme engine in module_path: "pixmap",
  (plenty of time the previous line)

Xlib:  extension "RANDR" missing on display ":1.0".
(migrate:23252): Gtk-WARNING **: 13:33:14.625: Unable to locate theme engine in module_path: "pixmap",
  (plenty of time the previous line)
xfwm4-Message: 13:33:14.628: Unsupported keyboard modifier '<Super>Tab'

** (xfdesktop:23235): WARNING **: 13:33:14.796: Failed to set the background '/usr/share/backgrounds/xfce/xfce-teal.jpg': GDBus.Error:org.freedesktop.DBus.Error.InvalidArgs: No such interface 'org.freedesktop.DisplayManager.AccountsService'
Xlib:  extension "RANDR" missing on display ":1.0".
Xlib:  extension "VMWARE_CTRL" missing on display ":1.0".
Xlib:  extension "RANDR" missing on display ":1.0".

(Notice that I remove dupplicate lines with a placeholder)

While on the client side (port 22 is naturally open on the server's firewall (ufw)) I open an SSH tunnel:

$ ssh -f -N -L 5901:localhost:5901 -l userroot server.domain.org

and then I try to connect but I'm facing this error (there are no more new lines in the server's log after this attempt):

$ xtightvncviewer localhost:5901

channel 2: open failed: connect failed: Connection refused
xtightvncviewer: VNC server closed connection

Both the server and the client are based on Ubuntu 18.04.5 LTS (GNU/Linux 5.4.0-77-generic x86_64).

How to fix this? Did I miss something while setting up the server?

hr flag
`/usr/bin/startxfce4: X server already running on display :1` seems... weird. It's *supposed* to be smart enough to choose the next available display - but I wonder if it's not, for some reason? Have you tried specifying a different display number explicitly (like `tightvncserver -localhost -geometry 1600x1280 :5`) and adjusting the port forward accordingly (i.e. 5905 in place of 5901)?
s.k avatar
cn flag
s.k
Yes it's weird because it's a headless server and I freshly installed `xfce4` and `tightvncserver`. If I manually specify `:5` it automatically starts on `:1`. There is no such `server.domain.org:5.pid` file but a `server.domain.org:1.pid` instead.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.