Search Engine: Elastic

Article ID: 128261, created on Feb 6, 2016, last review on Jul 19, 2017

  • Applies to:
  • Odin Automation Essentials

Symptoms

It is unable to edit a WordPress website: new browser window is opened with "Can’t connect to the server" error. The reason of such issue: nginx service is not getting started after the server reboot:

# systemctl --failed
  UNIT                           LOAD   ACTIVE SUB    DESCRIPTION
● nginx.service                  loaded failed failed Startup script for nginx service

In /var/log/nginx/error.log the following messages can be found:

 2015/12/28 11:58:57 [emerg] 1140#0: bind() to [xxx.xxx.xxx.xxx]:80 failed (99: Cannot assign requested address)

In journalctl the following records can be found:

# journalctl -u network.service -u network.target -u nginx.service -b
Feb 04 20:42:57 server.plesk.test nginx[352]: nginx: [emerg] bind() to xxx.xxx.xxx.xxx:80 failed (99: Cannot assign requested address)
...
Feb 04 20:42:57 server.plesk.test systemd[1]: Failed to start Startup script for nginx service.
Feb 04 20:42:57 server.plesk.test systemd[1]: Unit nginx.service entered failed state.
...
Feb 04 20:42:57 server.plesk.test network[268]: Bringing up interface eth0:
Feb 04 20:42:57 server.plesk.test dhclient[665]: DHCPREQUEST on eth0 to 255.255.255.255 port 67 (xid=0x4b684081)
Feb 04 20:42:57 server.plesk.test dhclient[665]: DHCPACK from xxx.xxx.xxx.xxx (xid=0x4b684081)
...
Feb 04 20:42:59 server.plesk.test network[268]: [  OK  ]

However nginx gets started manually without any issues:

# systemctl start nginx.service

Cause

Delay in assigning of IP address to interface. For example because of delayed response from DHCP server.

Resolution

  1. Backup nginx startup script /etc/systemd/system/multi-user.target.wants/nginx.service.

  2. Modify nginx startup script /etc/systemd/system/multi-user.target.wants/nginx.service and replace

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

    with

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

    This will ensure that nginx startup script will be executed after network is set up and all IP addresses are assigned.

  3. Reboot server.

d29f8259a7236d291b08be8147a45abd caea8340e2d186a540518d08602aa065

Email subscription for changes to this article
Save as PDF