Why would Apache refuse connections from the server it lives on?
December 19, 2007 2:10 PM   Subscribe

Why would a server start refusing http requests from itself? Curl, wget, lynx- all of them used to work, now I just get "connection refused". FTP still works, though, and it's only a problem with Apache- requests to the Lighttpd server on the same box work just fine.
posted by paul_smatatoes to Computers & Internet (6 answers total)
 
Is apache running? Have you tried stopping/restarting with apachectl? Have you checked the error logs? Have you tried running another daemon on port 80 to see if it's a firewall or port filtering issue?
posted by devilsbrigade at 2:18 PM on December 19, 2007


Did something change with name resolution lately? Here at work, we sometimes get the occasional server error that turns out to be because some genius registers "localhost" for a box name. do a "ping localhost", if you see any ip other than 127.0.0.1, it's something to consider.
posted by nomisxid at 3:08 PM on December 19, 2007


You probably aren't Listening on 127.0.0.1:80. You'll probably want to bind to that interface as well, or instruct your local http clients to use an interface to which the daemon is in fact bound.
posted by majick at 3:22 PM on December 19, 2007


Apache could be refusing requests from the box's default IP address. Try "ifconfig -a" to see what interfaces are configured, then "telnet -b " to try connecting from each of those interfaces' addresses to the Apache server instance.

And try "lsof -i" to see which processes are listening on which ports.

posted by nicwolff at 4:08 PM on December 19, 2007


sure there's no conflict with apache & lighttpd using the same port? Did your lighttpd installation take over port 80?
posted by slater at 3:08 AM on December 20, 2007


First thing: "netstat -anp |grep LISTEN". The first section of the output will show the open ports on your machine. 4th column shows the IP address and the port number. The default HTTP port is 80, so you should see something like ":::80" or "192.168.0.2:80", etc. The last column shows the process listening to that port, if you're running the command as root.

If you don't see a line ending in ":80", then nothing is listening on the default HTTP port. If there is something, make sure that it's Apache by looking at the last column (Apache appears as "httpd"; I don't now how lighthttpd appears as, but you can check further by looking more at the process number, etc)

If there is something with ":80", make sure it's listening to at least the local interface. IIRC, Apache listens to all interfaces, so you should see something like ":::80", which indicates all interfaces in netstat output. If it's something else, that that IP is what Apache is listening to.

If the netstat output looks correct, check if you haven't firewalled yourself. "iptables -L -n" should show your firewall configuration. I don't recall if SELinux will cause issues to.

Oh, and another main thing to do is look in the Apache logs /var/log/httpd/*log or somesuch. Firewall stuff may appear in /var/log/messages, depending on configuration.
posted by chengjih at 4:17 AM on December 20, 2007


« Older Where can I find more of the piano music of Yoko...   |   How poisonous are tomato vines? Newer »
This thread is closed to new comments.