Centos – Apache keeps failing and doesn’t restart cleanly – Address already in use: make_sock: could not bind to address

apache-2.2centos

I have a VPS with 1GB of RAM running CentOS 5.4

It also has plesk running with a number of wordpress websites running with no issues – most of the time.

Recently, it seems that every so often, apache seems to fall over. If you call www.mysite.com it seems to time out.

I attempt a restart of apache and get the following error.

Stopping httpd:                                            [FAILED]
Starting httpd: (98)Address already in use: make_sock: could not bind to address                                                [::]:80
(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
                                                           [FAILED]

Now I know 100% there is no other service running on port 80 other than apache. But apache doesn't seem to be responding to the stop command. It's almost like it's stuck in limbo!

Eventually I found that I can manually force apache to stop by running

killall -9 httpd

Then a restart command works.

My questions are:

1.) What would cause something like this to happen? The server doesn't get any major traffic to my knowledge.
2.) What can I do on the server to automatically execute the command above if it does happen when I'm not around to do it manually.

Thanks,

Ed

Best Answer

I had a similar problem with some plugins I was running, and until I diagnosed which one was causing the issue, I used cron to kill and restart apache and mysql every hour.