Apache Error: Address Already in Use – How to Resolve

apache-2.2rhel4

Apache (Linux Red Hat 4.1.x) fails to start with message: "Address already in use: make_sock: could not bind to address".

# /etc/init.d/httpd start
Starting httpd: (98)Address already in use: 
make_sock: could not bind to address 0.0.0.0:8000
no listening sockets available, shutting down
Unable to open logs
                                                       [FAILED]

Already tried to do:

killall -9 httpd

It looks like Apache is not running.
The port 8000 if free so nothing prevents Apache to occupy it. (nginx is on :80 as reverse proxy)

 # netstat -tulpn| grep :80
 tcp  0   0 0.0.0.0:8001    0.0.0.0:*   LISTEN 17181/DarwinStreami
 tcp  0   0 0.0.0.0:80      0.0.0.0:*   LISTEN 7962/nginx.conf

Possibly someone will have any thoughts on how to fix this?

UPD1: Apache config options are:

ServerRoot "/etc/httpd"
PidFile run/httpd.pid
Timeout 120
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 5

<IfModule prefork.c>
StartServers       1
MinSpareServers   5
MaxSpareServers   20
ServerLimit     200
MaxClients  200
MaxRequestsPerChild 2000

User apache
Group apache

DocumentRoot "/var/www/html"

NameVirtualHost *:8000

UPD2: Pid is not found:

# ls /etc/httpd/run/*.pid
/etc/httpd/run/crond.pid          /etc/httpd/run/sshd.pid
/etc/httpd/run/dhclient-eth0.pid  /etc/httpd/run/streamingadminserver.pid
/etc/httpd/run/haldaemon.pid      /etc/httpd/run/syslogd.pid
/etc/httpd/run/messagebus.pid     /etc/httpd/run/syslog-ng.pid
/etc/httpd/run/nginx.pid          /etc/httpd/run/xfs.pid

UPD3: server reboot doesn't helps 😉

UPD4: nc -l 8000 works OK, so the problem is not with a 8000 port but with Apache itself.

UPD5: "# /usr/sbin/lsof -i :8000" – outputs nothing

Best Answer

You have Listen directive for the same socket multiple times. Use grep -r Listen /etc/httpd/conf.d/*.conf /etc/httpd/conf/httpd.conf to find the culprit.

From apache documentation:

Error condition
Multiple Listen directives for the same ip address and port will result in an Address already in use error message.