Question

systemctl start vncserver@1 gives an error

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

Error:

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?

Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Ryan Quinn
DigitalOcean Employee
DigitalOcean Employee badge
April 20, 2018
Accepted Answer

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.

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 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
[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target
...

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

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel