How To Fix Error 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 When Start VNC Server.

After install VNC server on CentOS, when i run command # systemctl start vncserver@:1.service to start it, i meet bellow error message.

# systemctl start vncserver@:1.service
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.

I search google for the resolution, finally i find below steps.

  1. First login to linux OS with the user which you use in /etc/systemd/system/vncserver@:1.service file.
  2. Verify file /usr/bin/vncserver exist and execute it in the terminal.
    [happyzhaosong@MiWiFi-R4A-srv ~]$ /usr/bin/vncserver 
    
    You will require a password to access your desktops.
    
    Password:
    Verify:
    Would you like to enter a view-only password (y/n)? y
    Password:
    Verify:
    xauth:  file /home/happyzhaosong/.Xauthority does not exist
    
    New 'MiWiFi-R4A-srv:3 (happyzhaosong)' desktop is MiWiFi-R4A-srv:3
    
    Creating default startup script /home/happyzhaosong/.vnc/xstartup
    
    Creating default config /home/happyzhaosong/.vnc/config
    
    Starting applications specified in /home/happyzhaosong/.vnc/xstartup
    
    Log file is /home/happyzhaosong/.vnc/MiWiFi-R4A-srv:3.log
    
    
    
  3. Then it will create /home/happyzhaosong/.vnc/xstartup file.
  4. Edit file /home/happyzhaosong/.vnc/xstartup, add # at the beginning of line vncserver -kill $DISPLAY to remove it.
    if [ -e /usr/bin/gnome-session -o -e /usr/bin/startkde ]; then
       # vncserver -kill $DISPLAY
    fi
  5. If above method do not take effect, you can run command # rm -rf /tmp/.X11-unix/ with root user, and then reboot system.
    # rm -rf /tmp/.X11-unix/
  6. If above method do not take effect, you can edit file /etc/systemd/system/vncserver@:1.service and change Service —> Type from forking to simple.
    # vim /etc/systemd/system/vncserver@:1.service
    
    
    # Edit Service section, change Type=forking to Type=simple. 
    
    [Service]
    
    Type=forking
    
    #Type=simple
    
    
  7. Then run command # systemctl daemon-reload to update systemctl.

    # systemctl daemon-reload

6 thoughts on “How To Fix Error 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 When Start VNC Server.”

  1. So, i have a solution! Install x11vnc first. Then do this:

    1. Create a script:
    sudo nano /usr/local/bin/vnc-gdm
    It looks like this:
    #!/bin/bash
    id=$(id -u)
    x11vnc -loop -rfbport 5900 -forever -bg -xkb -noxrecord -noxfixes -noxdamage -many -create -display :0 -auth /run/user/$id/gdm/Xauthority
    2. Make the script executable:
    sudo chmod +x /usr/local/bin/vnc-gdm
    3. Create x11vnc for gdm:
    su -c ‘cat > /usr/share/gdm/greeter/autostart/vnc-gdm.desktop < /etc/xdg/autostart/vnc-users.desktop << EOF
    [Desktop Entry]
    Name=VNC for all users
    Type=Application
    Exec=x11vnc -loop -rfbport 5900 -repeat -many -noxkb -shared -noxdamage -find -auth guess
    Hidden=false
    EOF'

    Reboot, connect via VNC, and… it works! Thats it. Not that hard. But doing research and coming up with the solution was rly hard. Thanks to my good bro for helping me out. This solution isnt ideal but it satisfies all my needs, so i hope it will be usefull for someone just like it was for me.

    1. Appologies. Here are working files:

      file /usr/share/gdm/greeter/autostart/vnc-gdm.desktop
      looks like this:
      [Desktop Entry]
      Name=VNC for GDM
      Type=Application
      Exec=vnc-gdm
      Hidden=false

      file /etc/xdg/autostart/vnc-users.desktop
      looks like this:
      [Desktop Entry]
      Name=VNC for all users
      Type=Application
      Exec=x11vnc -loop -rfbport 5900 -repeat -many -noxkb -shared -noxdamage -find -auth guess
      Hidden=false

      /usr/local/bin/vnc-gdm script from my first comment works

  2. Angry frustrated user

    Oh, for crying out loud. Is there a single linux tutorial anywhere on the internet that actually works?

    “Can’t exec ‘/root/.vnc/xstartup’: Permission denied”

    But of course you don’t mention this at all, because like every single Linux tutorial in the entire world, you just assume it works and leave us hanging high end dry when it doesn’t actually work and spits out errors instead (which is ALWAYS). What a damn waste of time. Take this broken tutorial off the internet before you waste anybody else’s time.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.