Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My question is threefold:
1) how can I figure out what actually happened here,
2) how do I prevent it from happening again, and
3) can I configure Monit to detect and restart the server if it happens again?

Here's what happened:

My apache2 server hosted on an Ubuntu 9.10 RackSpace Cloud Server was down this morning -- and a restart failed [yes, I should have done a start instead -- but as restart falls back to start if there is no server to stop, it shouldn't matter] as follows:

user@host: sudo /etc/init.d/apache2 restart
* Restarting web server apache2                                                                                                                                                        
(13)Permission denied: make_sock: could not bind to address 
no listening sockets available, shutting down 
Unable to open logs

google to the rescue: I follow instructions in this post

for i in `ps auwx | grep -i nobody | awk {'print $2'}`; do kill -9 $i; done

and it starts without error. So, now I'm fixed, but need to know more.

edit: just saw this: Apache2 falling over -- hope it's not the same thing.

edit: so far, so good -- the rootkit check turns up clean --

share|improve this question
up vote 0 down vote accepted

I have run into three cases with various init scripts.

user@host has the privileges to shutdown apache2, but apache runs on port 80 which requires it be started by root. Use sudo to restart apache2. user@root should be able to reload apache2 though.

If user@host can start apache2, then you likely ran into a timing issue where apache tries to start before all the children have exited. Reload can be used apply many configuration changes, and does not require the old children to exit before the new servers are started. See the documentation for apachectl graceful.

The PID file got changed to a different PID by running start when the server is already running. Stop tries to stop the process from the PID file, but it is no longer running because it failed to get resources used by the old process.

share|improve this answer

On the Problem

The error you were getting means that apache could not start using port 80 since it is being used by another application.

Now on your solution:

for i in `ps auwx | grep -i nobody | awk {'print $2'}`; do kill -9 $i; done

The Command looks at all running processes (ps auxw) and looks for the listitems that contain "nobody" (grep -i nobody). The -i Parameter makes sure, that the filter is applied case-insensitive.

awk {'print $2'} limits the output to the second column.

And finally do kill -9 $i kills the remaining processes with signal 9 (KILL)

share|improve this answer
Thanks for breaking that down. But what I was really wondering was what might have happend. I ran "sudo netstat -nlp | grep 80" looking for anything listening to port 80 -- it came up empty. I understand that I might have the same error message if a process did not die correctly. My working assumption is that apache2 died, but didn't die correctly. Any way to check that theory? – marfarma Nov 22 '10 at 17:27

If you need to know what is running on a port

fuser 80/tcp

That will spit out the pid(s) of the apps running on the port

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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