I've a Raspberry Pi 4 with Ubuntu 18.04 server. I often control it via VNC, so I create a systemd service to start vnc4server at boot, it worked well until yesterday, now the service doesn't start. If I check with sudo systemctl status vnc4server@1, I get:

vnc4server@1.service - Start VNC server at startup
   Loaded: loaded (/etc/systemd/system/vnc4server@.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Tue 2020-03-31 07:14:41 CEST; 11s ago
  Process: 5103 ExecStart=/usr/bin/vnc4server -depth 24 -geometry 1280x720 :1 (code=exited, status=9
  Process: 5098 ExecStartPre=/usr/bin/vnc4server -kill :1 > /dev/null 2>&1 (code=exited, status=2)

mar 31 07:14:40 bornonpiday systemd[1]: Starting Start VNC server at startup...
mar 31 07:14:40 bornonpiday systemd[5098]: pam_unix(login:session): session opened for user icolumbrmar 31 07:14:40 bornonpiday systemd[5103]: pam_unix(login:session): session opened for user icolumbrmar 31 07:14:41 bornonpiday systemd[1]: vnc4server@1.service: Control process exited, code=exited stmar 31 07:14:41 bornonpiday systemd[1]: vnc4server@1.service: Failed with result 'exit-code'.
mar 31 07:14:41 bornonpiday systemd[1]: Failed to start Start VNC server at startup.

This is my systemd service file:

Description=Start VNC server at startup
After=syslog.target network.target

ExecStartPre=-/usr/bin/vnc4server -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vnc4server -depth 24 -geometry 1280x720 :%i
ExecStop=/usr/bin/vnc4server -kill :%i


If I start the server manually, it works. What's wrong?

  • add Wants=network-online.target in Unit section before After=.... line and append network-online.target to the line After=syslog.target network.target network-online.target and try again. – αғsнιη Mar 31 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.