When I try to start/restart the “vncserver” service, it fails with the below error.
# service vncserver restart Starting VNC server: no displays configured
Check for the Syntax of the /etc/sysconfig/vncservers file
1. The above error mostly occurs when you syntax error in the vncserver configuration file /etc/sysconfig/vncservers. You can verify if you have the configuration entries in below format.
# vi /etc/sysconfig/vncservers VNCSERVERS="2:myusername" VNCSERVERARGS="-geometry 800x600 -nolisten tcp -localhost"
2. One of the most common mistake users do is that they use unnecessary spaces in the configuration file. For example, following line exists in /etc/sysconfig/vncservers, and have typos such as space between “N” and “[user]”
# cat /etc/sysconfig/vncservers ... VNCSERVERS="N: [user]"
3. Sometimes you copy the configuration file lines from some book or website, which may also copy some junk characters. These are hard to find. You can use the below command to see if the file contains any junk characters.
# cat -evt /etc/sysconfig/vncservers | grep -v "#"
4. Another useful tip is to edit the below commented lines by hand which are already present in the configuration file /etc/sysconfig/vncservers.
# VNCSERVERS="2:myusername" # VNCSERVERARGS="-geometry 800x600 -nolisten tcp -localhost"
The above 2 lines are present by default for sample configuration. Make sure you remove the “#” in front of these lines before using them.
5. You should see output similar to shown below when the configuration file is with correct syntax.
# service vncserver start Starting VNC server: 2:root New 'geek.mylabserver.com:2 (root)' desktop is geek.mylabserver.com:2 Creating default startup script /root/.vnc/xstartup Starting applications specified in /root/.vnc/xstartup Log file is /root/.vnc/geek.mylabserver.com:2.log 3:user New 'geek.mylabserver.com:3 (user)' desktop is geek.mylabserver.com:3 Creating default startup script /home/user/.vnc/xstartup Starting applications specified in /home/user/.vnc/xstartup Log file is /home/user/.vnc/geek.mylabserver.com:3.log [ OK ]