I'm trying to configure VNC server for remote logins on a fresh install of CentOS 7, but I just can't seem to get it working right.

I've followed the install steps here including the firewall-cmd steps, but when I run systemctl status vncserver@:1.service, I see:

Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)
Active: inactive (dead) since <~4 seconds after start time>
Main PID: 1462 (code=exited, status=0/SUCCESS)

<start time> localhost.localdomain systemd[1]: Starting Remote desktop service (VNC)...
<start time+3> localhost.localdomaind systemd[1]: Started Remote desktop service (VNC).

When I instead try to run vncserver manually (as su - remote-user), the log output (in /home/remote-user/.vnc/localhost.localdomain:1.log) is:

  vncext: VNC extension running!
  vncext: Listening for VNC connections on all interface(s), port 5901
  vncext: created VNC server for screen 0
Killing Xvnc process ID 17085

Other thing that may be causing or contributing to the issue:

In /etc/systemd/system/vncserver@:1.service, the line:


Doesn't appear to generate any .pid files. /home/remote-user/.vnc contains no files ending in .pid; this may be because the vnc process doesn't live long enough to create them, but I'm not sure.


Just check your /home/username/.vnc/xstartup file and remove the last line

This is how it looked in my case:


vncserver -kill $DISPLAY

vncserver -kill $DISPLAY is definetely not something we want in xstartup, just remove it

  • While this might have solved your problem, please: Do not recommend to blindly erase the last line of the startup file. Be more specific of what should be searched.
    – ImHere
    Jan 11 '19 at 13:51
  • 1
    I was quite specific, do you usually read only the first line of the message or the whole post?
    – ilya.s
    Jan 11 '19 at 18:39
  • Commenting on a months-old post to thank @ilya.s for a sufficiently specific answer that pointed me in exactly the right direction. The last line of ~/.vnc/xstartup will always be vncserver -kill $DISPLAY for a fresh install, and besides, you provide the full contents of your file, and specifically mention that vncserver -kill $DISPLAY is the offending line. Apr 1 '19 at 18:03
  • This did prevent my vnc session from being terminated, but instead of showing the remote desktop, I got a black screen. There is something wrong with the display in my case.
    – Aaron Swan
    Feb 13 '20 at 15:46
  • @AaronSwan same, did you find how to solve the issue?
    – Dan M.
    May 20 at 12:24

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.