Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My server had a high load and I stopped Apache2 until the load receded using the killall -9 apache2. On starting Apache2 I got the error:

*# /etc/init.d/apache2 restart * Restarting web server apache2 httpd (pid 4457?) not running (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*

I then lsof | grep "*.www" and killed the process using port 80.

My question is how can a process still use port 80 even after I execute the kill all command?

share|improve this question
1  
Using 'kill -9` instead of service httpd stop (or equivalent) is kinda like nuking your house from orbit in order to turn a desk-light off. –  RedGrittyBrick Sep 28 '12 at 7:39
    
Under high load it takes very long to execute the graceful shut down of the Apache process. So you are saying using the kill command is a problem on its own? –  Paddington Sep 28 '12 at 7:46
    
Yes using killall -9 … can create problems. kill -9 (SIGKILL) is the most extreme way of stopping a process and should be a last resort, there are other signals (SIGINT, SIGQUIT, etc) you can send which give the process a chance to clean up and free up any resources it has locked or allocated. Secondly, you probably only need to stop the one process that is listening on port 80, to prevent further requests being accepted, you don't need to kill all the other worker processes. –  RedGrittyBrick Sep 28 '12 at 9:57

1 Answer 1

http://httpd.apache.org/docs/2.2/stopping.html

In order to stop or restart Apache, you must send a signal to the running httpd processes. There are two ways to send the signals. First, you can use the unix kill command to directly send signals to the processes. You will notice many httpd executables running on your system, but you should not send signals to any of them except the parent, whose pid is in the PidFile. That is to say you shouldn't ever need to send signals to any process except the parent. There are four signals that you can send the parent: TERM, USR1, HUP, and WINCH, which will be described in a moment.

To send a signal to the parent you should issue a command such as:

  kill -TERM `cat /usr/local/apache2/logs/httpd.pid`

My emphasis.

share|improve this answer

Your Answer

 
discard

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.