VNC server failed with “A VNC server is already running as :X” while vncserver restart. VNC server is not starting and getting the following error.
# service vncserver restart Shutting down VNC server: 3:testuser 5:testuser2 [FAILED] Starting VNC server: 3:ctmagt70 New 'test1:3 (testuser)' desktop is test1:3 Starting applications specified in /tsc/apps/testuser/.vnc/xstartup Log file is /tsc/apps/testuser/.vnc/tscpinf001:3.log 5:testuser2 A VNC server is already running as :5 [FAILED]
The Root Cause
This error may occur due to another process running at port 6005 that prevented vnc connection. VNC server listens for connections for a VNC client on following TCP ports.
5800+x, 5900+x, and 6000+x ( where x is the display that starts at zero by default )
- A VNC server on display 5 will listen on TCP ports 5805, 5905 and 6005
- Display 2 will listen on TCP ports 5802, 5902 and 6002
- Display 18 will listen on TCP ports 5818, 5918 and 6018
The following equation will explain the predefined use of each port related to VNC server.
5800+x - Used to send a user the java-based vncviewer application (if connect from a web browser to port 5800+x) 5900+x - VNC Client Port. The VNC protocol itself runs over this port. 6000+x - X Server Port
You may check the netstat output to verify vnc reserved ports are free at the time of issue.
tcp 0 0 22.214.171.124:6005 126.96.36.199:46968 ESTABLISHED 505 217168781 26544/pmrepagent off (0.00/0/0)
– Make the program listening on port 6000+X to listen on a different port.
– Workaround is to add the
– Backup /usr/bin/vncserver and add the following lines to /usr/bin/vncserver after the line “$cmd = “Xvnc :$displayNumber”;”
# vi /usr/bin/vncserver $cmd .= " -nolisten tcp";