VNC server is running but I cannot connect to it using VNC viewer

53,977

Solution 1

Here how to add a firewall exception (you'll need to open ports 5900 and 5800). Linux is not my strong side, so I hope this picture helps... CentOS firewall

Solution 2

You will need to do:

vi /etc/sysconfig/iptables

Then, you will find a file as follows:

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
# <add the line for eth>
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
# <add the line for ports>
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

With your correct eth in ifconfig, add the following lines to your iptables:

-A INPUT -i eth1 -j ACCEPT 
-A INPUT -m state --state NEW -m tcp -p tcp -m multiport --dports 5801:5803,5901:5903,6001:6003 -j ACCEPT

After the file is saved:

sudo service iptables restart
sudo service vncserver restart

You can have more information at: http://wiki.centos.org/HowTos/VNC-Server. However, you will see that they do not state: 5801:5803, which I have to add in order to get the VNCViewer working.

Regards,

Share:
53,977
Beginner
Author by

Beginner

Updated on September 18, 2022

Comments

  • Beginner
    Beginner almost 2 years

    I have installed VNC server on CentOS 5.8 and it is running, but I cannot connect to it using VNC viewer. I get the following error message:

    connect: Connection timed out(10060)

    What could be the problem?

    • EliadTech
      EliadTech over 11 years
      There could be many problems. Do you have network connection at all? Can you ping the CentOS? Do you have a firewall? Does the VNC service up and running? You can try do some more extesive checks using NMap - nmap.org
    • Beginner
      Beginner over 11 years
      I can connect to my server using putty. I checked vnsserver status using "service vncserver status" command and it is running.
    • EliadTech
      EliadTech over 11 years
      So, you should check out the firewall (if there's any), and test the VNC port with NMap.
    • Beginner
      Beginner over 11 years
      Thanks. I disabled ip tables. It's now working. But I should learn how to add exception to firewall.