Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

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 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 '14 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 '14 at 11:12

By default start-stop-daemon send SIGTERM to nginx process. It doesn`t 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 \


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

If your system has systemd, use it to kill the service:

# systemctl kill nginx.service

More information.

share|improve this answer
systemctl kill is what you mean?! – Ned64 Sep 8 '15 at 13:00
@Ned64 Yes, but I just wrote "use systemd kill" and put the link to the commands (to mean use the systemd kill option, I did not intend to write exact command, which is of course what you wrote, and I did not want to repeat given the link has it). Some editor here has formatted the text to look like systemd is a command and changed the link to 'more information text', after I submitted it. – user133216 Sep 8 '15 at 13:57
It's preferable to repeat the command; links are nice, but answers should be written as though the link isn't there, or if/when it breaks the answer becomes useless – Michael Mrozek Sep 8 '15 at 14:47

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.