Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

VNC Server: PID file /home/user/.vnc/backup:1.pid not readable (yet?) after start

Ran into this error on a server recently. We had to kill the VNC server because it stalled having its session running for an extended period.

# systemctl restart vncserver@:1
Job for vncserver@:1.service failed because a configured resource limit was exceeded. See "systemctl status vncserver@:1.service" and "journalctl -xe" for details.
# systemctl status vncserver@:1.service
● vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; disabled; vendor preset: disabled)
   Active: failed (Result: resources) since Thu 2020-02-13 07:33:00 CET; 31s ago
  Process: 40268 ExecStop=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
  Process: 44033 ExecStart=/usr/sbin/runuser -l user -c /usr/bin/vncserver %i -geometry 1920x1080 (code=exited, status=0/SUCCESS)
  Process: 44027 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 72488 (code=exited, status=0/SUCCESS)

Feb 13 07:32:57 backup systemd[1]: Starting Remote desktop service (VNC)...
Feb 13 07:33:00 backup systemd[1]: PID file /home/user/.vnc/backup:1.pid not readable (yet?) after start.
Feb 13 07:33:00 backup systemd[1]: Failed to start Remote desktop service (VNC).
Feb 13 07:33:00 backup systemd[1]: Unit vncserver@:1.service entered failed state.
Feb 13 07:33:00 backup systemd[1]: vncserver@:1.service failed.

Because we had to terminate the VNC server it couldn’t cleanly clear it’s tmp files, head into /tmp/.X11-unix/ and you’ll see a number of leftover files.

# ls /tmp/.X11-unix/
X1  X2  X3  X4  X5  X6  X7

Each file corresponds to its VNC user allotted slot, remove the sessions files that are problematic and that session should start successfully.

rm -f /tmp/.X11-unix/X1

We tried starting the VNC server but it still refused to start, we then proceeded to remove the VNC tmp files at the root of /tmp

# ls /tmp/.X
.X11-unix/ .X1-lock   .X2-lock   .X3-lock   .X4-lock   .X5-lock   .X6-lock   .X7-lock   .X8-lock   .XIM-unix/

This didn’t help either, we then proceed to throw the kitchen sink at Xvnc:

killall Xvnc

Started the service again:

systemctl start vncserver@:1.service

And Voila!

[root@backup tmp]# systemctl status vncserver@:1.service
● vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-02-13 08:11:35 CET; 2min 47s ago
  Process: 40268 ExecStop=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
  Process: 11854 ExecStart=/usr/sbin/runuser -l user -c /usr/bin/vncserver %i -geometry 1920x1080 (code=exited, status=0/SUCCESS)
  Process: 11851 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 11887 (Xvnc)
   CGroup: /system.slice/system-vncserver.slice/vncserver@:1.service
           ‣ 11887 /usr/bin/Xvnc :1 -auth /home/user/.Xauthority -desktop backup:1 (user) -fp catalogue:/etc/X11/fontpath.d -geometry 1920x1080 -pn -rfbauth /home/user/.vnc/passwd -rfbport 5901 -rfbwait 30000

Feb 13 08:11:32 backup systemd[1]: Starting Remote desktop service (VNC)...
Feb 13 08:11:35 backup systemd[1]: Started Remote desktop service (VNC).