Question

nginx service stopped randomly

I have a droplet set up with nginx web server. Yesterday, I noticed the application was not opening, so I checked nginx service and turns out it stopped for seeminly no reason. Manual service restart gets things back to normal. Screenshot for what I saw: https://i.imgur.com/mAfRV0y.png


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi @,

Most probably your Nginx was killed by the Droplet. This happens when your Droplet runs out of Memory. There are a couple of ways to go about the problem but first check your Nginx error log to see what was the exact error experienced. There are a couple of ways to check the error log:

If you want to monitor the log you can use :

  1. tail -f /var/log/nginx/error.log

If you want to check the last 200 lines:

  1. tail -n200 /var/log/nginx/error.log

I would go with the last command. From there you can check the date of the entry and see the exact error.

Another thing which I would suggest is adding SWAP to your Droplet. Here are a couple of tutorials which can help with that:

https://www.digitalocean.com/community/tutorial_collections/how-to-add-swap-space

Hello there,

My assumption here is that the droplet is running out of memory and the Nginx processes get killed.

You can check the Nginx error log using the bellow command:

  1. tail -f /var/log/nginx/error.log

Here is a link to an answer on how to troubleshoot common Nginx problems:

https://www.digitalocean.com/community/questions/how-to-troubleshoot-common-nginx-issues-on-linux-server

Another thing is adding SWAP to your droplet. A SWAP is an area on a hard drive that has been designated as a place where the operating system can temporarily store data that it can no longer hold in RAM. Basically, this gives you the ability to increase the amount of information that your server can keep in its working “memory”, with some caveats.

If you haven’t done this yet check our article:

https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-18-04

Hope that this helps!