Applicable to:
- Plesk Onyx for Linux
- Plesk Obsidian for Linux
Symptoms
-
After server reboot, nginx does not get started:
# systemctl --failed
UNIT LOAD ACTIVE SUB DESCRIPTION
● nginx.service loaded failed failed Startup script for nginx service - Domains are not working.
-
OS with
systemd
is installed (Debian 8, CentOS 7 and etc.). -
In
/var/log/nginx/error.log
the following messages can be found:CONFIG_TEXT: [emerg] 1140#0: bind() to [203.0.113.2]:80 failed (99: Cannot assign requested address)
-
In
journalctl
the following entries can be found:# journalctl -u network.service -u network.target -u nginx.service -b
nginx[352]: nginx: [emerg] bind() to 203.0.113.2:80 failed (99: Cannot assign requested address)
systemd[1]: Failed to start Startup script for nginx service.
systemd[1]: Unit nginx.service entered failed state.
network[268]: Bringing up interface eth0:
dhclient[665]: DHCPREQUEST on eth0 to 255.255.255.255 port 67 (xid=0x4b684081)
dhclient[665]: DHCPACK from 203.0.113.2 (xid=0x4b684081)
network[268]: [ OK ] -
However,
nginx
can be started manually without any issues:# systemctl start nginx.service
Cause
Delay in assigning of IP address to a network interface. For example, because of delayed response from DHCP server.
Resolution
-
Connect to the server using SSH.
-
Make sure that network interfaces are enabled on system boot:
-
for RHEL, CentOS, CloudLinux:
# grep -r "ONBOOT" /etc/sysconfig/network-scripts/ifcfg-*
/etc/sysconfig/network-scripts/ifcfg-lo:ONBOOT=yes
/etc/sysconfig/network-scripts/ifcfg-venet0:ONBOOT=yes
/etc/sysconfig/network-scripts/ifcfg-venet0:0:ONBOOT=yes -
for Debian and Ubuntu:
# grep auto /etc/network/interfaces
# This configuration file is auto-generated.
auto lo
auto venet0
auto venet0:0
-
-
Back up the nginx startup script
/etc/systemd/system/multi-user.target.wants/nginx.service:
# cp /etc/systemd/system/multi-user.target.wants/nginx.service{,.bk}
-
Make sure that the package
systemd-networkd
is installed on the server. Install it if it is not installed:-
for RHEL, CentOS, CloudLinux:
# yum install systemd-networkd
-
for Debian and Ubuntu:
Should be installed by default.The service will ensure that network interfaces are up and have IP addresses bound. For additional details, refer to http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
-
-
If Plesk 17.5 or older is used, proceed as follows to create the file
/etc/systemd/system/nginx.service.d/override.conf
with an nginx startup parameter to be executed only after the network is up and all IP addresses are assigned:-
Run the following command. It will open the default text editor on the server:
# systemctl edit nginx.service
Add the following line, save and exit the file:
CONFIG_TEXT: After=network-online.target remote-fs.target nss-lookup.target
-
- Reboot the server:
# reboot
If it does not help, additional action is required:
-
For SystemD add the following line in
[Service]
section in/etc/systemd/system/multi-user.target.wants/nginx.service
file:CONFIG_TEXT: ExecStartPre=/bin/sleep 10
Note: Increase timeout if needed.
-
For OS without SystemD, edit
/etc/init.d/nginx
adding sleep command to the start, so it should look like:# grep -i "start()" /etc/init.d/nginx
start() { sleep 20 -
Reboot the server:
# reboot
Comments
0 comments
Please sign in to leave a comment.