systemctl start vncserver@1 gives an error


Description=Start TightVNC server at startup

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



root@**server**:~# sudo systemctl start vncserver@1
Job for vncserver@1.service failed because the control process exited with error code.
See "systemctl  status vncserver@1.service" and "journalctl  -xe" for details.
root@**server**:~# sudo systemctl status vncserver@1
● vncserver@1.service - Start TightVNC server at startup
   Loaded: loaded (/etc/systemd/system/vncserver@.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2018-04-19 18:34:49 UTC; 18s ago
  Process: 3369 ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :1 (code=exited, status=1/FAIL
  Process: 3364 ExecStartPre=/usr/bin/vncserver -kill :1 > /dev/null 2>&1 (code=exited, status=2)

Apr 19 18:34:49 **server** systemd[1]: Starting Start TightVNC server at startup...
Apr 19 18:34:49 **server** systemd[3364]: pam_unix(login:session): session opened for user **user** by (uid=0)
Apr 19 18:34:49 **server** systemd[3369]: pam_unix(login:session): session opened for user **user** by (uid=0)
Apr 19 18:34:49 **server** systemd[1]: vncserver@1.service: Control process exited, code=exited status=1
Apr 19 18:34:49 **server** systemd[1]: Failed to start Start TightVNC server at startup.
Apr 19 18:34:49 **server** systemd[1]: vncserver@1.service: Unit entered failed state.

Any idea what I’m doing wrong?


Some further inspection revealed this: pam_systemd(login:session): Failed to release session: Access denied

To give some additional context, if I setup the vncserver@.service for root, it works just fine. The problem is only when trying to do it for the user I created. To which I did give root access.

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

My issue was with SELinux Look at output from ausearch… Mine showed vncserver being denied.

$ ausearch -c ‘(ncserver)’ --raw <<<look for vncserver>>>

enable it by: $ ausearch -c ‘(ncserver)’ --raw | audit2allow -M my-ncserver $ semodule -i my-ncserver.pp

Finally!!! $ systemctl start vncserver@1

and no more error… The other alternative would be to disable selinux…

I inputted this command ausearch -c ’(ncserver)’ –raw and the output was -raw is an unsupported option.

I see this post has 9k views, so in case this helps anyone: I was getting this error because I’d accidentally copy-pasted the config file from a VNC installation tutorial without removing a file path that the tutorial author put at the top of the code block:

/etc/systemd/system/vncserver@.service    <-- this line shouldn't be here
Description=Start TightVNC server at startup

So make sure you haven’t got any typos and stuff like the above mistake in your config.

The error you shared leads me to believe this may be an issue related to the permissions given to the user account you are running the service under. Are you able to start vncserver normally from the command line?

If you update your systemd service to use the user “root” does the service start properly? (not that I’d recommend keeping this configuration, but testing this can confirm if it’s a permissions issue with the user account specified).

Personally I switched from using VNC on my servers to using x2go when needing a remote desktop. It tends to be easier to set up, better performing and more secure since it tunnels over ssh. This script can be used to install and start x2go with xfce on Ubuntu 14.04 and newer.

According to this website:

You need to disable SELinux (suboptimal, I know) with the following commands:

# setenforce 0
# sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux

I just installed Fedora 30 and the template file had:

/usr/bin/vncserver -kill %i


/usr/bin/vncserver -kill :%i

But your example has :%i

Just wanted to note it here for anybody else who has the same problem.