It took me a while to find out, but as of some recent-ish update, I can't stop Nginx on any of my Ubuntu 12.04 or Ubuntu 14.04 servers.

I run sudo service nginx stop, and I get nginx start/running, process 16178.

I try sudo service nginx stop again, and I get nginx start/running, process 16206.

Note how the process number changes.

In /var/log/syslog I can see why:

Jun 11 11:57:51 kernel: [2318556.994508] init: nginx main process ended, respawning.

Nginx is respawned every time I run sudo service nginx stop. It never comes to a full stop.

I tried updating Ubuntu, rebooted and I re-installed my servers on local test-images (I use Puppet). Nothing makes any difference. I also tried searching for bugs relating to this without avail.

Does anyone know how I can fix this problem? I'd like to be able to run sudo service nginx stop and have all nginx processes stopped as a result.


It seems you nginx server is handle by an upstart process.

Look in the /etc/init folder, and check if there is not a file which handles nginx.

grep -r nginx /etc/init

Then edit this file, and remove the respawn option in the config file.


You can stop nginx process using sudo nginx -s quit

You can see in /etc/init/nginx