Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 &
~            
share|improve this question
1  
Stopping the iptables service doesn't necessarily mean that you're allowing all traffic. It just means that you're falling back to the set policy which could be ACCEPT or DROP, depending. –  pboin Dec 26 '11 at 19:25

2 Answers 2

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.

share|improve this answer
    
I edited the question (added the vnc configs) –  Auxiliary Dec 26 '11 at 19:37
1  
resolved - Thanks for mentioning the vnc config file. At first I thought you meant the xstartup file. I checked the config file and found this line: VNCSERVERARGS[1]="-geometry 800x600 -nolisten tcp -nohttpd -localhost" which refused connection. –  Auxiliary Dec 26 '11 at 20:08

Start the VNC server then try telneting using:

telnet localhost [port number]

Where [port number] is whatever port you configured. If the server is actually running you should see something like "RFB 003.003" as the output. If you get connection refused, then likely the server is not running.

[Edit]

I'm with @pboin on this. I think your iptables is still blocking.

Edit /etc/sysconfig/iptables file:

# vi /etc/sysconfig/iptables

Add

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport [port number]  -j ACCEPT

Where [port number] is the port you're using. Then restart iptables using:

# service iptables restart

Then try the remote connect again.

share|improve this answer
1  
Also, you can check using netstat -an | grep [port number] and ps aux | grep vnc to make sure the server is up. –  n1reu Dec 26 '11 at 19:22
    
I got RFB 003.008. So is it running? Would the port be shown as closed, if the server is not run on that port? (Yeh, I've checked it with netstat before, it seems up.) –  Auxiliary Dec 26 '11 at 19:23
    
@Auxiliary If you can telnet in that way then the server is at least listening on localhost. So what happens if you remotely attempt to telnet to the port (using the public IP)? Do you get that same output or do you get a connection refused? –  n1reu Dec 26 '11 at 19:40
    
I just checked the vnc log after the telnet and it says it's had an accepted connection from 127.0.0.1 but remotely I get connection timed out. –  Auxiliary Dec 26 '11 at 19:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.