/
/
Failed to start Nginx, error: «99: Cannot assign requested address»

Failed to start Nginx, error: «99: Cannot assign requested address»

Symptoms

When starting or rebooting the operating system, Nginx encounters an IP address assignment error:

nginx: [emerg] bind() to <ip-address>:1501 failed (99: Cannot assign requested address)

Solution

There are two possible solutions:

  • Directly specify a list of services after which Nginx should start.
  • Set a delay before the Nginx service starts.

List of services

In the configuration file at /etc/systemd/system/multi-user.target.wants/nginx.service, replace the line with the After directive with the following:

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

Restart the server and check Nginx status:

service nginx status

Delay before start

In the file at /etc/systemd/system/multi-user.target.wants/nginx.service, in the Service section, replace the line with the ExecStartPre directive with the following:

ExecStartPre=/bin/sh -c '/bin/sleep <time>'; /usr/sbin/nginx -t -q -g 'daemon on; master_process on;'

Restart the server and check Nginx status:

service nginx status