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

I install lighttpd in one server using port 81.

The problem is that the port is closed, and I don't know how to open the port.

Regards,
Pedro

share|improve this question

3 Answers 3

up vote 2 down vote accepted

Netstat:
From what you have said, sounds like the port might not actually be listening. If port 81 was listening on all interfaces you should see something like the following line from 'netstat -tapnl':

tcp        0      0 192.168.1.82:81       0.0.0.0:*               LISTEN      -               
tcp        0      0 192.168.131.1:81        0.0.0.0:*               LISTEN      -               
tcp        0      0 192.168.21.1:81        0.0.0.0:*               LISTEN      -               
tcp        0      0 127.0.0.1:81            0.0.0.0:*               LISTEN      -

The 4th Coloumn is the IP address that have something listening on them. With 127.0.0.1 being the loopback interface. You might also see 0.0.0.0:81 for all interfaces instead.

Iptables:
So if you did see it listening on 127.0.0.0 or 0.0.0.0 from the netstat output, you should be able to telnet to it from the same server if you have this common iptables rule from the 'sudo iptables -L -v' command:

1198K  183M ACCEPT     all  --  lo     any     anywhere             anywhere

Which if under the INPUT chain mean accept all incoming connections into the loopback interface. Also, notice the first two columns. This is how many packets / bytes are matching that rule, so you should see the counters changing with DROP or ACCEPT rules accordingly. It is a way to see if the rules are 'catching' the packets.

Conclusion:
Make sure lighttpd is actually running 'sudo ps aux | grep lighttpd' (assuming that is process name). If it isn't, start it with 'sudo /etc/init.d/lighttpd start'. Then if you still don't see it listening look in the logs at /var/log/lighttpd . Lastly, post your lighttpd configuration. If you are trying to start the process as a non root user you also won't be able to bind it to 81 because that is a privileged port (even though the process might run as another user).

The above assumes you have ssh access or something similar and are on the machine itself. That is the best place to start, eliminates and complexity of the router with its possible NAT. You can do NAT with iptables, but not sure if you can do it with the loopback interface, and that would be an odd thing to do if you can.

share|improve this answer

Define "closed". If netstat -ltn shows 0.0.0.0:81 in the "Local Address" column, then lighttpd is listening (and hence the port isn't actually closed), and it's something firewall-related. If you know you're using a firewall management package, then modifying that to allow new inbound connections to port 81 is the way to go, otherwise you can try opening the port "by hand" with something like iptables -I INPUT 1 -p tcp --dport 81 -j ACCEPT (although if you are running a firewall manager of some sort, that change might get wiped out, and will definitely get wiped out on reboot). More information about your system can elicit more detailed and more useful answers.

share|improve this answer
    
don't work! :( Port still closed –  Pedro Aug 7 '09 at 10:38

How are you trying to access it? i.e. what address are you entering in the address bar? are you use localhost, or 127.0.0.1 or an external address or domain?

share|improve this answer
    
Excellent question. –  womble Aug 7 '09 at 9:50
1  
the external address. I make telnet www.ssss.xxx 81 from remote server and nothing, connection refused –  Pedro Aug 7 '09 at 10:08
    
@pcamacho what sort of internet connection is this? A home DSL line? Or in a datacentre? What's your firewall set up? Can you access a webserver on port 80? –  Rory Aug 7 '09 at 10:11
1  
yes I can connect using telent www.xxx.yy 80 it's one Dedicated Debian Server that I run several websites in Apache Vhosts –  Pedro Aug 7 '09 at 10:15
1  
If you're going via another router, you'll need to open up the firewall on that device as well. It sounds like the machine itself isn't at fault (you can test this by trying to connect to localhost:81) –  womble Aug 7 '09 at 10:59

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.