Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When I stop nginx like this on ubuntu 12.04, I get the following errors:

$ sudo service nginx stop
Stopping nginx: nginx.
$sudo service nginx start
Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

I have to use this to fix it. Why does't stopping the service kill the nginx process? That is confusing!

share|improve this question
    
Maybe it' the answer? stackoverflow.com/questions/10939072/… –  enedil Mar 10 at 23:29
    
Stop nginx, then execute: netstat -tulpn | grep ':80' Paste the line here. Maybe the process status will tell us something –  alfredocambera Apr 5 at 11:12
add comment

1 Answer 1

By default start-stop-daemon send SIGTERM to nginx process. It doesnt guarantee stop process. Fix: in file/etc/init.d/nginx` change in section "stop" string

start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \

to

start-stop-daemon --stop --retry=TERM/30/KILL/5 --quiet --pidfile /var/run/$NAME.pid \

That fix send SIGKILL (kill -9) if SIGTERM don`t stop process.

And ensure please, that path to pid-file pid /var/run/nginx.pid; in /etc/nginx/nginx.conf and path --pidfile /var/run/$NAME.pid in /etc/init.d/nginx are the same.

share|improve this answer
add comment

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.