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:

Submit an answer
Answer a question...

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.

Site Moderator
Site Moderator badge
March 9, 2022

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:

Site Moderator
Site Moderator badge
March 9, 2022

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:

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:

Hope that this helps!