NGINX is down & Fails to restart - more than 10000 tries failed

Rohit_V

Registered
Jul 29, 2021
3
1
3
India
cPanel Access Level
Root Administrator
Since couple of days, I'm flooded with notification that NGinx is down and the System tried more than 10,000 times but failed to check or restart it.
I checked with my VPS Hosting company and they said they cant help resolve this. So, trying here, before uninstalling Nginx Manager.

Notification:


Service Name​
nginx​
Service Status​
failed​
Notification​
The service “nginx” appears to be down.​
Service Check Method​
The system’s command to check or to restart this service failed.​
Number of Restart Attempts​
10,503​
Service Check Raw Output​
(XID *****) The “nginx” service is down.
The subprocess “/usr/local/cpanel/scripts/restartsrv_nginx” reported error number 255 when it ended.​

Startup Log​
Jul 28 17:27:36 myserver,com nginx[3323]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Jul 28 17:27:37 myserver,com nginx[3323]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jul 28 17:27:37 myserver,com nginx[3323]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Jul 28 17:27:37 myserver,com nginx[3323]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jul 28 17:27:37 myserver,com nginx[3323]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Jul 28 17:27:38 myserver,com nginx[3323]: nginx: [emerg] still could not bind()
Jul 28 17:27:38 myserver,com systemd[1]: nginx.service: control process exited, code=exited status=1
Jul 28 17:27:38 myserver,com systemd[1]: Failed to start nginx - high performance web server.
Jul 28 17:27:38 myserver,com systemd[1]: Unit nginx.service entered failed state.
Jul 28 17:27:38 myserver,com systemd[1]: nginx.service failed.​
 
Last edited:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
6,951
921
313
cPanel Access Level
Root Administrator
Hey there! Was Nginx installed through WHM on the system? Normally it would be using alternate ports and then sending the traffic to Apache, so it might be best to open a ticket with our team so we can check that configuration on our end.
 

ankeshanand

Well-Known Member
Mar 29, 2021
194
58
103
India
cPanel Access Level
Root Administrator
Since couple of days, I'm flooded with notification that NGinx is down and the System tried more than 10,000 times but failed to check or restart it.
I checked with my VPS Hosting company and they said they cant help resolve this. So, trying here, before uninstalling Nginx Manager.

Notification:


Service Name​
nginx​
Service Status​
failed​
Notification​
The service “nginx” appears to be down.​
Service Check Method​
The system’s command to check or to restart this service failed.​
Number of Restart Attempts​
10,503​
Service Check Raw Output​
(XID *****) The “nginx” service is down.
The subprocess “/usr/local/cpanel/scripts/restartsrv_nginx” reported error number 255 when it ended.​

Startup Log​
Jul 28 17:27:36 myserver,com nginx[3323]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Jul 28 17:27:37 myserver,com nginx[3323]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jul 28 17:27:37 myserver,com nginx[3323]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Jul 28 17:27:37 myserver,com nginx[3323]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jul 28 17:27:37 myserver,com nginx[3323]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Jul 28 17:27:38 myserver,com nginx[3323]: nginx: [emerg] still could not bind()
Jul 28 17:27:38 myserver,com systemd[1]: nginx.service: control process exited, code=exited status=1
Jul 28 17:27:38 myserver,com systemd[1]: Failed to start nginx - high performance web server.
Jul 28 17:27:38 myserver,com systemd[1]: Unit nginx.service entered failed state.
Jul 28 17:27:38 myserver,com systemd[1]: nginx.service failed.​
Seems like Port 80 and 443 are already occupied by some other process and because of that NGINX is not able to BIND to that port. Try the Following:
Code:
lsof :i:80
lsof -i:443
You will get the PID and Name of the Process occupying the Port. Try to Gracefully shut down and disable the process using systemctl and if its corrupted or in loop, Kill the process using PID and Then Start NGINX, It would work.
 

ankeshanand

Well-Known Member
Mar 29, 2021
194
58
103
India
cPanel Access Level
Root Administrator
@cPRex
I have created ticket

@ankeshanand , @HostNoc
On checking, recent Tickets with my Hosting provider, it is seen that they changed the port of Apache from 81, 444 to 80, 443 (this was done in mid-Jun)
They did this because all my Sites on VPS went down suddenly.
Which provider is it? Its actually wrong is some provider access your VPS and Its Internal Files without Customer's permission.
 

Rohit_V

Registered
Jul 29, 2021
3
1
3
India
cPanel Access Level
Root Administrator
@cPRex
Christopher from Cpanel team, helped change back the ports. The continuous notifications of Nginx failure have stopped since.

@ankeshanand
I'm not sure if mentioning provider is ok here?(forum rules/promotion/negative PR for provider ..etc?)
As I mentioned, they did it to resolve issue of Sites gone down suddenly. (they acted on ticket raised)
The wrong thing on their part was lack of understanding of what ports Apache & Nginx should run on if both are set to run.



Christopher from CP team, further suggested the initial issue of Sites gone down can be due to FPM Child process limit hit. so will be monitoring that.

Thanks all for your time & responses.
 

AlphaPrime

Registered
Aug 23, 2021
4
0
1
Romania
cPanel Access Level
Root Administrator
systemctl restart nginx
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

After I add in /etc/nginx/nginx.conf

# Load ModSecurity dynamic module
load_module /etc/nginx/modules/ngx_http_modsecurity_module.so;

The path to the module is a shortcut for /usr/lib64/nginx/modules/ngx_http_modsecurity_module.so - with this path dosen't work either