1

I've set up TigerVNC server on Ubuntu 22.04LTS. I've created a file at /etc/systemd/system/vncserver@.service to make the service start on start-up, using the following configuration:

[Unit]
Description=Start TigerVNC server at startup
After=syslog.target network.target

[Service] Type=simple User=monitor Group=monitor WorkingDirectory=/home/monitor

PIDFile=/home/monitor/.vnc/%H:%i.pid ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1 ExecStart=/usr/bin/vncserver -verbose -depth 24 -geometry 1280x800 -localhost :%i ExecStop=/usr/bin/vncserver -kill :%i

[Install] WantedBy=multi-user.target

Running the start command /usr/bin/vncserver -verbose -depth 24 -geometry 1280x800 -localhost in the command line manually works fine, and I can successfully connect using a remote SSH-tunnelled VNC connection. There are no error messages or warnings shown at all.

However, using sudo systemctl start vncserver@1 doesn't work. journalctl shows the following log output:

Apr 23 14:23:35 cucumber systemd[1]: Starting Start TigerVNC server at startup...
Apr 23 14:23:35 cucumber vncserver[5446]: vncserver: Option 2>&1: Unrecognized!
Apr 23 14:23:35 cucumber vncserver[5446]: vncserver usage:

... vncserver outputs its entire --help output here

Apr 23 14:23:35 cucumber systemd[1]: Started Start TigerVNC server at startup. Apr 23 14:23:35 cucumber vncserver[5455]: Starting /usr/bin/Xtigervnc :1 -localhost=1 -desktop cucumber:1 (monitor) -rfbport 5901 -PasswordFile /home/mon> Apr 23 14:23:35 cucumber vncserver[5455]: New Xtigervnc server 'cucumber:1 (monitor)' on port 5901 for display :1. Apr 23 14:23:35 cucumber vncserver[5455]: Use xtigervncviewer -SecurityTypes VncAuth -passwd /home/monitor/.vnc/passwd :1 to connect to the VNC server. Apr 23 14:23:35 cucumber vncserver[5455]: Starting session via '/home/monitor/.vnc/xstartup' Apr 23 14:23:35 cucumber vncserver[5455]: Log file is /home/monitor/.vnc/cucumber:5901.log

... a couple of 'activating service'/'successfully activated' statements here

Apr 23 14:23:38 cucumber org.a11y.Bus[5489]: X connection to :1 broken (explicit kill or server shutdown). Apr 23 14:23:38 cucumber org.gtk.vfs.Daemon[5509]: A connection to the bus can't be made Apr 23 14:23:38 cucumber xfconfd[5483]: Name org.xfce.Xfconf lost on the message dbus, exiting. Apr 23 14:23:38 cucumber tumblerd[5569]: Name org.freedesktop.thumbnails.Cache1 lost on the message dbus, exiting. Apr 23 14:23:38 cucumber tumblerd[5569]: Name org.freedesktop.thumbnails.Manager1 lost on the message dbus, exiting. Apr 23 14:23:38 cucumber tumblerd[5569]: Name org.freedesktop.thumbnails.Thumbnailer1 lost on the message dbus, exiting. Apr 23 14:23:38 cucumber org.gtk.vfs.Daemon[5744]: A connection to the bus can't be made Apr 23 14:23:38 cucumber vncserver[5779]: Killing Xtigervnc process ID 5456... success! Apr 23 14:23:38 cucumber systemd[1]: vncserver@1.service: Deactivated successfully. Apr 23 14:23:38 cucumber systemd[1]: vncserver@1.service: Consumed 2.477s CPU time.

Here's the output in /home/monitor/.vnc/cucumber:5901.log:

Xvnc TigerVNC 1.12.0 - built 2022-03-25 17:06
Copyright (C) 1999-2021 TigerVNC Team and many others (see README.rst)
See https://www.tigervnc.org for information on TigerVNC.
Underlying X server release 12101003, X.Org

Sat Apr 23 15:01:09 2022 vncext: VNC extension running! vncext: Listening for VNC connections on local interface(s), port 5901 vncext: created VNC server for screen 0 [mi] mieq: warning: overriding existing handler (nil) with 0x562410d9e400 for event 2 [mi] mieq: warning: overriding existing handler (nil) with 0x562410d9e400 for event 3 3NI3X0 New Xtigervnc server 'cucumber:1 (monitor)' on port 5901 for display :1. 3NI3X0 Use xtigervncviewer -SecurityTypes VncAuth -passwd /home/monitor/.vnc/passwd :1 to connect to the VNC server. /usr/bin/startxfce4: X server already running on display :1 gpg-agent: a gpg-agent is already running - not starting a new one

(xfwm4:9407): xfwm4-WARNING **: 15:01:10.009: Unsupported GL renderer (llvmpipe (LLVM 13.0.1, 256 bits)).

(wrapper-2.0:9449): GLib-GIO-CRITICAL **: 15:01:10.358: g_file_new_for_path: assertion 'path != NULL' failed

(wrapper-2.0:9449): GLib-GIO-CRITICAL **: 15:01:10.358: g_file_monitor_file: assertion 'G_IS_FILE (file)' failed

(wrapper-2.0:9449): GLib-GObject-WARNING **: 15:01:10.358: invalid (NULL) pointer instance

(wrapper-2.0:9449): GLib-GObject-CRITICAL **: 15:01:10.358: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed

(wrapper-2.0:9449): Gtk-WARNING **: 15:01:10.358: Attempting to add a widget with type GtkToggleButton to a container of type XfcePanelPlugin, but the widget is already inside a container of type XfcePanelPlugin, please remove the widget from its existing container first.

** (wrapper-2.0:9448): WARNING **: 15:01:10.365: No outputs have backlight property

(wrapper-2.0:9454): Gtk-WARNING **: 15:01:10.367: Negative content width -1 (allocation 1, extents 1x1) while allocating gadget (node button, owner XfceArrowButton)

(wrapper-2.0:9449): Gtk-WARNING **: 15:01:10.369: Negative content width -3 (allocation 1, extents 2x2) while allocating gadget (node button, owner GtkToggleButton)

(wrapper-2.0:9448): Gtk-CRITICAL **: 15:01:10.385: gtk_icon_theme_has_icon: assertion 'icon_name != NULL' failed

(wrapper-2.0:9448): Gtk-CRITICAL **: 15:01:10.386: gtk_icon_theme_has_icon: assertion 'icon_name != NULL' failed

(wrapper-2.0:9448): Gtk-CRITICAL **: 15:01:10.386: gtk_icon_theme_has_icon: assertion 'icon_name != NULL' failed

(wrapper-2.0:9448): Gtk-CRITICAL **: 15:01:10.387: gtk_icon_theme_has_icon: assertion 'icon_name != NULL' failed

(wrapper-2.0:9448): Gtk-WARNING **: 15:01:10.394: Negative content width -3 (allocation 1, extents 2x2) while allocating gadget (node button, owner PowerManagerButton)

** (xfce4-power-manager:9485): WARNING **: 15:01:10.407: Failed to get name owner: GDBus.Error:org.freedesktop.DBus.Error.NameHasNoOwner: Could not get owner of name 'org.xfce.PowerManager': no such name

** (xfce4-power-manager:9485): WARNING **: 15:01:10.407: Failed to get name owner: GDBus.Error:org.freedesktop.DBus.Error.NameHasNoOwner: Could not get owner of name 'org.freedesktop.PowerManagement': no such name

Xfce power manager is not running Xlib: extension "DPMS" missing on display ":1".

(xfce4-power-manager:9485): xfce4-power-manager-WARNING **: 15:01:10.411: Monitor is not DPMS capable

(wrapper-2.0:9447): Gtk-WARNING **: 15:01:10.414: Negative content width -3 (allocation 1, extents 2x2) while allocating gadget (node button, owner PulseaudioButton) Xfce Power Manager: Another power manager is already running

** (xiccd:9505): WARNING **: 15:01:10.448: EDID is empty Connection failure: Connection refused pa_context_connect() failed: Connection refused

(xfce4-power-manager:9485): GLib-GObject-WARNING **: 15:01:10.454: ../../../gobject/gsignal.c:2613: signal 'Changed' is invalid for instance '0x55897a97d0c0' of type 'GDBusProxy'

** (xiccd:9505): CRITICAL **: 15:01:10.459: failed to create colord device: failed to obtain org.freedesktop.color-manager.create-device auth

(xfce4-power-manager:9485): xfce4-power-manager-WARNING **: 15:01:10.470: could not map keysym 1008ffa8 to keycode

Another notification daemon is running, exiting

(xfce4-power-manager:9485): xfce4-power-manager-WARNING **: 15:01:10.476: Unable to inhibit systemd sleep: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Permission denied

** (xfce4-power-manager:9485): WARNING **: 15:01:10.476: No outputs have backlight property

(xfce4-power-manager:9485): xfce4-power-manager-WARNING **: 15:01:10.490: Failed to get keyboard max brightness level : GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: Object does not exist at path “/org/freedesktop/UPower/KbdBacklight”

** (light-locker:9537): ERROR **: 15:01:10.514: session_id is not set, is /proc mounted with hidepid>0?

** (xiccd:9505): WARNING **: 15:01:12.848: Exiting

(xfsettingsd:9431): libxfce4ui-WARNING **: 15:01:12.849: ICE I/O Error

(xfsettingsd:9431): libxfce4ui-WARNING **: 15:01:12.849: Disconnected from session manager.

(Thunar:9438): thunar-WARNING **: 15:01:12.851: Name 'org.xfce.FileManager' lost on the message dbus.

(Thunar:9438): thunar-WARNING **: 15:01:12.851: Name 'org.freedesktop.FileManager1' lost on the message dbus. xfsettingsd: Another instance took over. Leaving...

(xfce4-power-manager:9485): libxfce4ui-WARNING **: 15:01:12.850: ICE I/O Error

(xfce4-power-manager:9485): libxfce4ui-WARNING **: 15:01:12.854: Disconnected from session manager.

** (xfce4-power-manager:9485): WARNING **: 15:01:12.856: Error: The connection is closed

** (xfce4-power-manager:9485): WARNING **: 15:01:12.856: Error: The connection is closed

The X session cleanly exited! Killing Xtigervnc process ID 9358...XIO: fatal IO error 25 (Inappropriate ioctl for device) on X server ":1.0" after 20 requests (20 known processed) with 0 events remaining.

Sat Apr 23 15:01:12 2022 ComparingUpdateTracker: 0 pixels in / 0 pixels out ComparingUpdateTracker: (1:-nan ratio)

(x-window-manager:9685): Gtk-WARNING **: 15:01:12.872: cannot open display: :1 success!

1 Answers1

4

Yes, at least two online tutorials (1, 2) for running TigerVNC via systemd on Ubuntu 20.04 no longer work on Ubuntu 22.04, in part because of this problem.

Try changing the ExecStartPre line in your systemd unit file to the following:

ExecStartPre=-/usr/bin/vncserver -kill :%i

Then do a systemctl daemon-reload and systemctl start vncserver@1.

Why?

  • It appears that Ubuntu 22.04 is now passing the output redirection (2>&1) to the vncserver command as an argument (rather than interpreting it as shell). The redirection doesn't appear to be required.
  • The minus sign (-) prevents any non-zero exit code of this command from causing the service to fail (reference, see "Table 1. Special executable prefixes"). I don't know for certain if it's needed, but it cannot hurt and the DigitalOcean tutorial does it.

Note, I also had to install the dbus-x11 package because my /etc/vnc/xstartup file uses the dbus-launch command.