2

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

webdevbyjoss
  • 123
  • 1
  • 5

2 Answers2

10

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.

Mircea Vutcovici
  • 16,706
  • 4
  • 52
  • 80
  • 1
    Thanks!! "# grep -r Listen /etc/httpd/" produced the list of directives where I was able to locale 8000 port value multiple times. Hope this thread will help everyone to debug such issues in advance. – webdevbyjoss Dec 02 '11 at 15:06
0

I get this sometimes when the PID file wasn't removed during the previous apache stop. If the PID is there, try removing it before starting up again.

I also get this sometimes when I'm trying to start apache up using an account other than what apache was configured to run as.

mahnsc
  • 1,776
  • 13
  • 11
  • according to Apache configuration we have "PidFile run/httpd.pid", where can I find that file? – webdevbyjoss Dec 02 '11 at 14:00
  • Ok,finally wasn't able to locale that file under "/etc/httpd/run/" – webdevbyjoss Dec 02 '11 at 14:22
  • Anyway thanks for your attention! My case was about accidentally declaring "Listen" multiple times, while dealing with sub-domains and multiple system administrators on the same server :) – webdevbyjoss Dec 02 '11 at 15:08