Question

Nginx server crashing occasionally

I have ubuntu server with nginx that crashing from time to time and i cant handle why.

Ubuntu 20.04.4 Nginx version: nginx/1.18.0 (Ubuntu)

My logs:

2022/11/22 22:14:11 [info] 4076541#4076541: Using 32768KiB of shared memory for nchan in /etc/nginx/nginx.conf:102
2022/11/22 22:14:12 [notice] 4076546#4076546: signal process started
2022/11/22 22:14:15 [notice] 4076550#4076550: signal process started
2022/11/22 22:14:18 [notice] 4076553#4076553: signal process started
2022/11/22 22:14:18 [error] 4076553#4076553: open() "/run/nginx.pid" failed (2: No such file or directory)

What should I do to fix this?

My nginx working well now, and after: ‘systemctl start nginx.service’ nginx started without any errors but from practice if i’ll wait some time (it’s may be day or one week) nginx will crash again


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.

Bobby Iliev
Site Moderator
Site Moderator badge
November 23, 2022

Hi there,

Indeed as Sergio mentioned, it is best to check the /var/log/syslog for more information no why the service might be crashing.

I’ve seen a similar problem in the past caused by Certbot.

The following lines in the renewal config files at /etc/letsencrypt/renewal/* with outdated versions of Certbot might cause the problem:

post_hook = service nginx start
pre_hook = service nginx stop

What I had to do was to upgrade Cerbot to the latest version:

sudo apt-get update
sudo apt-get install certbot python-certbot-nginx

After that upgrade the pre_hook and post_hook lines should no longer be in the renewal config files.

Hope that this helps!

Best,

Bobby

Hi @sergeybremenskiy,

It is difficult to find out the problem without more information.

Is there anything relevant in /var/log/syslog?

The official nginx debugging page may be helpful.

It may also be that the process works correctly and that at a specific moment a process reach the memory limit that your Droplet supports and it is crashed, it would be enough to add more memory to your droplet.

Hope that helps you,

Sergio Turpín

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up