Server Httpd Issue

Rupak Bhattacharjee

New Member
Joined
May 19, 2017
Messages
6
Reaction score
0
Credits
0
When I tried to restart the httpd service in my server it shows something like this.

Starting httpd: (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

I tried rebooting the server, copying the httpd.conf file from a running server, but failed. Could you please help me out?
 


Hey, welcome to Linux.org!

That error is stating that something is already using port 80.. but also the 'unable to open logs' makes me wonder as well.

1st - you're restarting as root, correct?
2nd - what's the output of: 'service httpd status' (it should give you a line or two saying stopped, running, etc..)
3rd - can you view the output of the error logs? (in /var/log/httpd/)
4th - what's the output of: 'netstat -tanp |grep :80' (will tell you if somehting is listening on 80 already)

Oops.. 5th - what distribution and version are you running? (ie: CentOS 6.9)

Rob
 
Thanks Rob. The answers are as follows.

1st: Yes
2nd: httpd dead but subsys locked
3rd: no log file generated.
4th:
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2139/httpd
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1874/pmtahttpd
tcp 1 0 217.174.241.102:38820 167.114.0.200:80 CLOSE_WAIT 29933/httpd
tcp 1 0 217.174.241.102:38810 167.114.0.200:80 CLOSE_WAIT 2145/httpd
tcp 1 0 217.174.241.102:38828 167.114.0.200:80 CLOSE_WAIT 2143/httpd
tcp 1 0 217.174.241.102:38832 167.114.0.200:80 CLOSE_WAIT 2148/httpd
tcp 1 0 217.174.241.102:38822 167.114.0.200:80 CLOSE_WAIT 2144/httpd
tcp 1 0 217.174.241.102:38826 167.114.0.200:80 CLOSE_WAIT 2141/httpd
tcp 1 0 217.174.241.102:38824 167.114.0.200:80 CLOSE_WAIT 2147/httpd
tcp 1 0 217.174.241.102:38834 167.114.0.200:80 CLOSE_WAIT 2142/httpd
tcp 1 0 217.174.241.102:38830 167.114.0.200:80 CLOSE_WAIT 2146/httpd

5th: CentOS release 6.9 (Final)
 
Oops, i'm sorry.. I forgot that you replied on this.

Ok, look in /var/run/ and /var/lock/subsys/ for http lock files. Remove them if they're there, then try to restart httpd:
Code:
service httpd restart
 
Ok,

That means the httpd config does not have errors..

Can you telnet to port 80 of your server to see what it answers with? The netstat output shows it's listening there already:

Code:
telnet server.com 80
 
Ok,

That means the httpd config does not have errors..

Can you telnet to port 80 of your server to see what it answers with? The netstat output shows it's listening there already:

Code:
telnet server.com 80

Trying 52.8.126.80...
Connected to server.com.
Escape character is '^]'.
^[
HTTP/1.1 400 Bad Request
Server: nginx
Date: Fri, 26 May 2017 12:15:14 GMT
Content-Type: text/html
Content-Length: 166
Connection: close

<html>
<head><title>400 Bad Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>
Connection closed by foreign host.
 
Ok, so you have an nginx (apache alternative) running currently on port 80. If you're trying to start apache it won't be able to get a hold of the port 80 socket because nginx already has it.

If you want to start apache instead of nginx then you can do:
Code:
service nginx stop
service httpd start

and it should work.. otherwise, if nginx is what you really want to be running, and it's not working correctly, you can service nginx restart to see if it recovers.

If you find that you really do want apache instead of nginx, then you want to disable nginx from starting at boot with:
Code:
chkconfig nginx off

If this is a server you inherited from a previous co-worker, I'd find out which web server is supposed to be running before changing things up :)

Rob
 

Members online

No members online now.

Top