Plesk Nginx fail to start on boot

On a Debian Server with Plesk Control Panel, Nginx did not start on boot.

On checking status, i get

root@server:~# systemctl status nginx
* nginx.service - Startup script for nginx service
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
   Active: failed (Result: exit-code) since Mon 2018-01-22 18:30:19 CET; 2min 21s ago
  Process: 700 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
  Process: 646 ExecStartPre=/usr/bin/test $NGINX_ENABLED = yes (code=exited, status=0/SUCCESS)

Jan 22 18:30:19 server.hostonnet.com nginx[700]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Jan 22 18:30:19 server.hostonnet.com nginx[700]: nginx: [emerg] bind() to 82.211.1.93:80 failed (99: Cannot assign requested address)
Jan 22 18:30:19 server.hostonnet.com nginx[700]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jan 22 18:30:19 server.hostonnet.com systemd[1]: nginx.service: control process exited, code=exited status=1
Jan 22 18:30:19 server.hostonnet.com systemd[1]: Failed to start Startup script for nginx service.
Jan 22 18:30:19 server.hostonnet.com systemd[1]: Unit nginx.service entered failed state.
root@server:~# 

/var/log/nginx/error_log had following error

2018/01/22 18:30:19 [emerg] 700#0: bind() to 82.211.1.93:80 failed (99: Cannot assign requested address)

Solution

Edit nginx.service file

vi /etc/systemd/system/multi-user.target.wants/nginx.service

Find line

ExecStartPre

Add above (on a new line)

ExecStartPre=/bin/sleep 60

Find

After=network.target remote-fs.target nss-lookup.target

Replace with

After=network-online.target remote-fs.target nss-lookup.target

Reload service file

systemctl daemon-reload

Here is my modified nginx.service file

root@root1229:~# cat /lib/systemd/system/nginx.service
[Unit]
Description=Startup script for nginx service
After=network-online.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
EnvironmentFile=-/etc/default/nginx

.include /etc/default/nginx.systemd
# tuning of limits settings:
# 1. fill required limits as described in systemd.exec(5)
# 	nginx.systemd content example for number of open files:
# 	[Service]
# 	LimitNOFILE=8192
# 2. restart service

ExecStartPre=/bin/sleep 60
ExecStartPre=/usr/bin/test $NGINX_ENABLED = "yes"
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx

ExecReload=/usr/bin/test $NGINX_ENABLED = "yes"
ExecReload=/usr/sbin/nginx -t
ExecReload=/bin/kill -s HUP $MAINPID

ExecStop=/bin/kill -s QUIT $MAINPID

[Install]
WantedBy=multi-user.target
root@root1229:~# 

plesk

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *