Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

Each time or often enough when I run apt-get update then upgrade, I get a nginx 502 error. Rebooting the server brings everything back up.

I'm guessing I have to restart nginx each time?

BTW, how can I figure out where my nginx is installed so I can call reboot on it?

its been a while since I terminalled into this test vps (still learning)

share|improve this question
Do you see the 502 from the apt-get command? I'm guessing the problem is apt-get is configured to use a mirror that you do not have permission to access. – mfarver Jan 29 '11 at 3:15
Add output of apt command. – alvosu Jan 29 '11 at 3:30
up vote 2 down vote accepted

I do not know what /etc/init.d/nginx in Ubuntu does, but I can explain what mechanisms Nginx has so that you can upgrade it without interrupting service.

If you'd install/upgrade Nginx from the sources, you'd certainly build it at the first. Then you issue make install to copy new binary.

Then, you have to learn what is PID of Nginx "master" process:

ps ax | grep nginx

and find "master" process PID in the output. Let's assume it's 123.

Then send USR2 signal to the master process:

kill -USR2 123

You can review Nginx's error.log and the list of processses (ps ax | grep nginx) to make sure that a new instance of Nginx has started.

Issue WINCH signal:

kill -WINCH 123

Now the new Nginx instance will get requests. And the old worker processes shutdown gracefully. Again, review error.log to make sure everything goes fine.

And finally,

kill -QUIT 123

will shutdown old Nginx master. After that, your system has new Nginx installed and running.

This procedure ensures all the connections are served without interruptions.

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.