My nginx is stopping by itself, several times a day!

December 25, 2016 739 views
Nginx Control Panels Ubuntu 16.04

My nginx is stopping by itself, several times a day!

    Hello guys. I am in a tightening, I am in trouble, time and other my sites are offline, when I go to check my nginx server is stopped, I call again, when it is a few hours later, the time varies a lot, it again, I have to send one <Service nginx start> and this is a vice that lasts almost a month. I've been analyzing, there is no precise time, so it's not a crazy cron, people what do I do? I use ubuntu 16.04 / 32 + virtualmin + nginx + php7.0-fpm + mysql 5.7. I did not do anything on the server by the time he started it !! It is not about load, because I have little access and a lot of resources left over, I worked a lot configuring this and suddenly about 2 months later after I finished configuring everything, the server starts that this crazy behavior
: '(

4 Answers

those "lot of configuring" might left some bad configuration. did you checked the error log after it turned off by the way? you might find whats the main reason of turning it down from there.

You say it's not about lot, you configured it but however, I would still look at syslog to verify it.

Behavior you explained is usually due to running out of memory. Even with everything well configured and not under load it can happen if you use small Droplet.

Open syslog with your favorite text editor:

  • sudo nano /var/log/syslog

Find nginx (if it makes problem) and look for Out of Memory, OOM, OOM-killer entries.
If you find any, that means you are running out of memory and that you need to upgrade.

You have two options:

  1. upgrade Droplet
  2. and free variant - add Swap space to your Droplet.
One of the easiest way of increasing the responsiveness of your server and guarding against out of memory errors in your applications is to add some swap space. In this guide, we will cover how to add a swap file to an Ubuntu 16.04 server. &lt;$&gt;[warning] [label...

Thanks for reply :-)

I've been looking at the nginx logs in /etc/nginx/error.log> nano and noticed that the service is complaining about a duplicate config in a determinate line:

2016/12/25 10:02:00 [warn] 7454 # 7454: duplicate MIME type "text / html" in /etc/nginx/nginx.conf:57

 And on this line I see this:

 Gziptypes text / plain application / x-javascript text / css application / javascript text / javascript application / xml + rss text / xml text / html application / json application / vnd.ms-fontobject application / Font-truetype application / x-font-ttf TEXT / HTML application / xml font / eot font / opentype font / otf image / svg + xml image / vnd.microsoft.icon;
Gzip
disable "MSIE [1-6] .";

   True that the chance to have a nonsense in the middle is great, because I never leave anything in stock, I always give an adornment in the directrives of my services, fail2ban, firewall, knocking, everything full of the fails, soon chance of giving poop is bigger too , But all for safety and low machine performance.

  But I did not want to be config, because I have an apache server with ubuntu 14 in stock, that's a good nut, I just installed it, without moving or installing anything, just installed virtualmin in an opendkim package and already put a vhost in it through a restore , And is giving even a bug to stop apache and with the problem of being mysql when not apache.

   Then I removed what it said to be duplicity: text / html Then restart the server and no longer adding a new line in the log as it was rule to say it was duplicated, well, but the service always started, with no errors printed on my console.

 

     I do not think there's a relationship. I just made the reset and wait now to see if it continues in the madness, I'm thinking it's something virtualmin, because I have apache on another server, which is almost the same, and worse, stopping msql together. When website crashes, abou the dashboard of virtualmin, spying the services status tab, and it is, or apache, or mysql stopped. Now on that other server, with nginx, it's direct, all the time. Almost 6 times a day nginx has the service stopped, and having to start tight player of the virtualmin and does not roll, so I do by the terminal happens, so that e'algo in that panel: / ¬¬ 'already filled in the offical forum of them this dawn And waiting for feedback.

So my myqsl is also stopping, so I accessed the logs, and they are all empties !! And my server fully stocked, with no improvement in the settings, are with mysql stopping several times a day, so I noticed that my exfoliation of not having nor creating swap memory could be the problem, and max_connection in my.cnf I increased from 30 to 300.

  Let's see if it still stops those services.

My log error in syslog:

Dec 25 06:25:14 host1 systemd[1]: Stopping A high performance web server and a reverse proxy server...
Dec 25 06:25:14 host1 systemd[1]: Stopped A high performance web server and a reverse proxy server.
Dec 25 06:25:14 host1 systemd[1]: nginx.service: Start request repeated too quickly.
Dec 25 06:25:14 host1 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Dec 25 06:25:14 host1 systemd[1]: Stopped A high performance web server and a reverse proxy server.
Dec 25 06:25:14 host1 systemd[1]: nginx.service: Start request repeated too quickly.
Dec 25 06:25:14 host1 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Dec 25 06:25:14 host1 systemd[1]: Stopped A high performance web server and a reverse proxy server.
Dec 25 06:25:14 host1 systemd[1]: nginx.service: Start request repeated too quickly.
Dec 25 06:25:14 host1 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Dec 25 06:25:14 host1 systemd[1]: Stopped A high performance web server and a reverse proxy server.
Dec 25 06:25:14 host1 systemd[1]: nginx.service: Start request repeated too quickly.
Dec 25 06:25:14 host1 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Dec 25 06:25:14 host1 systemd[1]: Stopped A high performance web server and a reverse proxy server.
Dec 25 06:25:14 host1 systemd[1]: nginx.service: Start request repeated too quickly.
Dec 25 06:25:14 host1 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Dec 25 06:25:14 host1 systemd[1]: Stopped A high performance web server and a reverse proxy server.
Dec 25 06:25:14 host1 systemd[1]: nginx.service: Start request repeated too quickly.
Dec 25 06:25:14 host1 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Dec 25 06:25:14 host1 systemd[1]: Stopped A high performance web server and a reverse proxy server.
Dec 25 06:25:14 host1 systemd[1]: nginx.service: Start request repeated too quickly.
Dec 25 06:25:14 host1 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Dec 25 06:25:21 host1 postfix/pickup[30041]: 1BABA611E8: uid=0 from=<root>
Dec 25 06:25:21 host1 postfix/cleanup[30935]: 1BABA611E8: message-id=20161225062521.1BABA611E8@host1.mydomainname.com
Dec 25 06:25:21 host1 postfix/qmgr[2032]: 1BABA611E8: from=root@host1.mydomainname.com, size=2523, nrcpt=1 (queue active)
Dec 25 06:25:23 host1 postfix/local[30937]: 1BABA611E8: to=root@host1.mydomainname.com, orig_to=<root>, relay=local, delay=2.5, delays=0.14/0.01/0/2$
Dec 25 06:25:23 host1 postfix/qmgr[2032]: 1BABA611E8: removed
Dec 25 06:25:35 host1 kernel: [138700.451395] [UFW BLOCK] IN=eth0 OUT= MAC=76:d8:73:68:0e:7b:cc:e1:7f:a8:17:f0:08:00 SRC=85.106.15.128 DST=198.2$
Dec 25 06:25:54 host1 kernel: [138719.871779] [UFW BLOCK] IN=eth0 OUT= MAC=76:d8:73:68:0e:7b:cc:e1:7f:a8:17:f0:08:00 SRC=184.105.139.77 DST=198.$
Dec 25 06:25:56 host1 kernel: [138721.725356] [UFW BLOCK] IN=eth0 OUT= MAC=76:d8:73:68:0e:7b:cc:e1:7f:a8:17:f0:08:00 SRC=78.188.44.215 DST=198.2$
Dec 25 06:27:36 host1 kernel: [138822.130770] [UFW BLOCK] IN=eth0 OUT= MAC=76:d8:73:68:0e:7b:cc:e1:7f:a8:1b:f0:08:00 SRC=188.68.224.51 DST=198.2$
Dec 25 06:27:37 host1 kernel: [138823.128328] [UFW BLOCK] IN=eth0 OUT= MAC=76:d8:73:68:0e:7b:cc:e1:7f:a8:1b:f0:08:00 SRC=188.68.224.51 DST=198.2$
Dec 25 06:27:39 host1 kernel: [138825.132363] [UFW BLOCK] IN=eth0 OUT= MAC=76:d8:73:68:0e:7b:cc:e1:7f:a8:1b:f0:08:00 SRC=188.68.224.51 DST=198.2$
Dec 25 06:27:43 host1 kernel: [138829.144766] [UFW BLOCK] IN=eth0 OUT= MAC=76:d8:73:68:0e:7b:cc:e1:7f:a8:1b:f0:08:00 SRC=188.68.224.51 DST=198.2$
Dec 25 06:27:46 host1 kernel: [138832.185621] [UFW BLOCK] IN=eth0 OUT= MAC=76:d8:73:68:0e:7b:cc:e1:7f:a8:1b:f0:08:00 SRC=188.68.224.51 DST=198.2$
Dec 25 06:27:47 host1 kernel: [138833.185235] [UFW BLOCK] IN=eth0 OUT= MAC=76:d8:73:68:0e:7b:cc:e1:7f:a8:1b:f0:08:00 SRC=188.68.224.51 DST=198.2$
Dec 25 06:28:59 host1 kernel: [138904.574321] [UFW BLOCK] IN=eth0 OUT= MAC=76:d8:73:68:0e:7b:cc:e1:7f:a8:17:f0:08:00 SRC=185.46.191.49 DST=198.2$
Dec 25 06:30:01 host1 CRON[31059]: (root) CMD (/etc/webmin/status/monitor.pl)

It can not be real, this system can not be in overload, I have a server with 9 domains, but all together do not have 5 thousand access per month !!!
It has resource left over on the server, I have 4gb of swap, 60 of swap properties (priority to use)
The use of the resource of the machine is not even in 45% of ram, swap hardly use, and cpu gets much free time !! When in use 15% max. !!!

Thanks all.

Have another answer? Share your knowledge.