Velvet Star Monitor

Standout celebrity highlights with iconic style.

news

New main PID does not belong to service, and PID file is not owned by root

Writer Mia Lopez

When running vncserver (tightvncserver) on Xubuntu 18.04 as a service, I get this error

New main PID 2095 does not belong to service, and PID file is not owned by root. Refusing.

My service file looks like this

/etc/systemd/system/vncserver@.service
[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target
[Service]
Type=forking
User=user
PAMName=login
PIDFile=/home/user/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target

According to this bug report, it has something to do with this change in systemd.

Any suggestions on updating my service file so it works with systemd again?

0

2 Answers

You're probably referencing the 16.04 version of this Digital Ocean VNC guide rather than the 18.04 version. In the 18.04 version the /etc/systemd/system/vncserver@.service file should look like this:

[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target
[Service]
Type=forking
User=sammy
Group=sammy
WorkingDirectory=/home/sammy
PIDFile=/home/sammy/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target

Remember to replace all 4 instances of sammy with your own user name. The 18.04 version fixed my issues with the same PID file is not owned by root errors that you reported.

Commenting out PAMName=login solved the issue on 16.04

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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