Tightvnc server crashing randomly?

i followed this guide

https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-20-04

but sometimes I cannot connect to tightvnc when running status on the server, I see it's not active any more

In the journal I find

Aug 06 01:56:49 myapp1 vncserver[6198]: Log file is /home/ubuntu/.vnc/myapp1:2.log
Aug 06 01:56:49 myapp1 systemd[1]: [email protected]: Can't open PID file /home/ubuntu/.vnc/myapp1:1.pid (yet?) after start: Operation not permitted

When I run status I get:

$ sudo systemctl status vncserver@1
● [email protected] - Start TightVNC server at startup
     Loaded: loaded (/etc/systemd/system/[email protected]; enabled; vendor preset: enabled)
     Active: failed (Result: core-dump) since Fri 2021-08-06 01:40:08 UTC; 14min ago
   Main PID: 918 (code=dumped, signal=SEGV)

Aug 06 00:55:58 myapp1 dbus-daemon[1012]: [session uid=1001 pid=1006] Successfully activated service 'org.gnome.evolution.dataserver.AddressBook10'
Aug 06 00:55:58 myapp1 org.freedesktop.thumbnails.Thumbnailer1[1956]: Registered thumbnailer /usr/bin/gdk-pixbuf-thumbnailer -s %s %u %o
Aug 06 00:55:58 myapp1 org.freedesktop.thumbnails.Thumbnailer1[1956]: Registered thumbnailer /usr/bin/gdk-pixbuf-thumbnailer -s %s %u %o
Aug 06 00:55:58 myapp1 dbus-daemon[1012]: [session uid=1001 pid=1006] Successfully activated service 'org.freedesktop.thumbnails.Thumbnailer1'
Aug 06 00:55:58 myapp1 dbus-daemon[1012]: [session uid=1001 pid=1006] Activating service name='org.gtk.vfs.Metadata' requested by ':1.11' (uid=1001 pid=1547 comm="xfdesktop " label="unconfined")
Aug 06 00:55:58 myapp1 dbus-daemon[1012]: [session uid=1001 pid=1006] Successfully activated service 'org.gtk.vfs.Metadata'
Aug 06 01:40:08 myapp1 xfce4-notifyd[1933]: xfce4-notifyd: Fatal IO error 11 (Resource temporarily unavailable) on X server :1.
Aug 06 01:40:08 myapp1 org.a11y.Bus[1065]: X connection to :1 broken (explicit kill or server shutdown).
Aug 06 01:40:08 myapp1 systemd[1]: [email protected]: Main process exited, code=dumped, status=11/SEGV
Aug 06 01:40:08 myapp1 systemd[1]: [email protected]: Failed with result 'core-dump'.

Restarting tightvncserver service does not work. sudo systemctl start vncserver@1

After I reboot, tightvnc server works fine again. But I don't want to constantly reboot my server. Any ideas?

I'm open to a different vnc server as well.


Edit: I think I just found the solution: use TigerVNC instead:

sudo apt purge tightvncserver
sudo apt install tigervnc-standalone-server tigervnc-viewer

This solved a crash that I had repeatedly.


Before I used this solution, I had at least a way to restart the service without rebooting: When you run

sudo systemctl start vncserver@1     #this fails
sudo systemctl status vncserver@1    #this shows why

You will see that it fails because /tmp/.X1-lock file still exists, and after removing that, it complains about /tmp/.X11-unix.

So, if you do:

sudo rm -r /tmp/.X11-unix /tmp/.X1-lock
sudo systemctl start vncserver@1

You can restart the service without needing a reboot