When connecting to VNC server we may get the error "Unable to connect to server" in the client side.
When try to restart the VNC service from the server will get the following error:
[myuser@xxxxxx tmp]# service vncserver restart
Shutting down VNC server: 3:myuser [FAILED]
Starting VNC server: 3:myuser
Warning: xxx.xxx.xxx:3 is taken because of /tmp/.X3-lock
Remove this file if there is no X server xxx.xxx.xxx.xxx:3
A VNC server is already running as :3 [FAILED]
As we can see there is problem with the lock file and socket file.
1. Remove lock file and socket
[myuser@xxxxxx tmp]# rm -rf /tmp/.X3-lock
[myuser@xxxxxx tmp]# rm -rf /tmp/.X11-unix/X3
2. Restart vnc service
[myuser@xxxxxx tmp]# service vncserver restart