CentOS port closed even when iptables is stopped

centosiptablesportvnc

I've recently got a VPS running CentOS 6.X, I installed Gnome and configured VNC. vncserver is running fine, but I can't connect to it. I checked the ports from outside and noticed that port 5901 is closed. I edited the iptables and restarted the iptables service but nothing happens. I even stopped the iptables service but the port seems closed. What's going on?

Thanks in advance.

[EDIT] OK, to be honest, I'm not sure if the vncserver is running right or not. It doesn't give any errors, but there are some gnome related errors in its logs. But could this have anything to do with the port being closed?

[EDIT] These are 2 vnc configs (xstartup) that I tried:

#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
# xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
xterm -geometry 1024x768 -ls -name "$VNCDESKTOP Desktop" &
twm &
~            

and this one:

#!/bin/sh

( while true; do xterm; done ) &

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
# xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
xterm -geometry 1024x768 -ls -name "$VNCDESKTOP Desktop" &
gnome-session &
~            

Best Answer

first verify your vnc servers is actually running :

ps -ef | grep -i vnc

then make sure it is listening

netstat -nlptu

if that does not work, look for errors in your log, and also try disabling selinue

setenforce 0

also posting your vnc config would help.