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
systemd is installed (Debian 8, CentOS 7 and etc.).
/var/log/nginx/error.log the following messages can be found:
[emerg] 1140#0: bind() to [203.0.113.2]:80 failed (99: Cannot assign requested address)
journalctl the following entries can be found:
# journalctl -u network.service -u network.target -u nginx.service -b
nginx: nginx: [emerg] bind() to 203.0.113.2:80 failed (99: Cannot assign requested address)
systemd: Failed to start Startup script for nginx service.
systemd: Unit nginx.service entered failed state.
network: Bringing up interface eth0:
dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67 (xid=0x4b684081)
dhclient: DHCPACK from 203.0.113.2 (xid=0x4b684081)
network: [ OK ]
nginx gets started manually without any issues:
# systemctl start nginx.service
Delay in assigning of IP address to a network interface. For example, because of delayed response from DHCP server.
- Make sure that network interfaces are enabled on system boot (use one of the following commands depending on OS used - Red Hat based or Debian based):
# grep "ONBOOT" /etc/sysconfig/network-scripts/ifcfg-eth0
# grep auto /etc/network/interfaces
Back up nginx startup script
- Configure nginx startup script to be executed after network is up and all IP addresses are assigned: open file
After=network.target remote-fs.target nss-lookup.target
After=network-online.target remote-fs.target nss-lookup.target
4. Reboot the server
Note: If steps above was not helped on CentOS 7, then follow this article