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.

I just installed Fedora 30 and the template file had:

/usr/bin/vncserver -kill %i

not

/usr/bin/vncserver -kill :%i

But your example has :%i

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

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

Try DigitalOcean for free

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

Sign up

Become a contributor for community

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

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.