enter image description here

I have a remote Linux server, I was trying to connect to it using TigerVNC, I can sucessfully connect to my remote server, when the server iptable is not running, but after I start running iptables, I am unable to connect to remote server using VNC

Error : "The connection was refused by the host computer"

Connecting as IP_ADDRESS::5901

Do I need to add entry in iptables to all all to connect to VNC server, or any suggestions?


  • can you share the output of your iptables -L ?
    – Raza
    Mar 21, 2016 at 21:49
  • I have attached the screenshot above...Thanks
    – Mat55
    Mar 21, 2016 at 22:23
  • In above pic I was trying to add one single source IP [], but please ignore that,....I want all IPs should be able to connect.
    – Mat55
    Mar 21, 2016 at 22:33
  • You can also add 6000 or 6001 for the X Server port
    – Raza
    Mar 21, 2016 at 22:35

1 Answer 1


For VNC, you need to modify your rules as follows

for i in 0 1 2 3
  iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 580$i  -j ACCEPT
  iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 590$i  -j ACCEPT
  iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 600$i  -j ACCEPT

This is for 4 VNC connections. If you need more or less, you need to adjust the number of times the loop should run.

  • Does position matters in the IPTABLES,.....I already have some in that file.
    – Mat55
    Mar 21, 2016 at 22:20
  • Position matters as iptables entries get processed from top to bottom and process stops on the first matching rule. But if you try to introduce the same rule twice, I think the later coming one kicks the older rule out in the sequence of events.
    – MelBurslan
    Mar 21, 2016 at 22:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .