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

9
  • Could you post the main part of your Apache config (with any identifying information taken out, of course)
    – Andy Smith
    Dec 2, 2011 at 13:50
  • updated initial question Dec 2, 2011 at 13:58
  • selinux problem? Add 8000 to the httpd ports.
    – AndreasM
    Dec 2, 2011 at 14:12
  • in case of "selinux" problem is can produce the "Starting httpd: (13)Permission denied" but not "Address already in use" Dec 2, 2011 at 14:15
  • 1
    Can you share the output of lsof -i :8000 ?
    – thinice
    Dec 2, 2011 at 14:46

2 Answers 2

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.

1
  • 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. Dec 2, 2011 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.

3
  • according to Apache configuration we have "PidFile run/httpd.pid", where can I find that file? Dec 2, 2011 at 14:00
  • Ok,finally wasn't able to locale that file under "/etc/httpd/run/" Dec 2, 2011 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 :) Dec 2, 2011 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.