Workaround of race condition between systemd and nginx.

Das, Jagannath jadas at
Wed Dec 30 18:49:06 UTC 2015

How to reproduce this issue?

From: "Daniel K." <dk at<mailto:dk at>>
Reply-To: "nginx-devel at<mailto:nginx-devel at>" <nginx-devel at<mailto:nginx-devel at>>
Date: Wednesday, December 30, 2015 at 11:58 PM
To: "nginx-devel at<mailto:nginx-devel at>" <nginx-devel at<mailto:nginx-devel at>>
Subject: Re: Workaround of race condition between systemd and nginx.

On 12/30/2015 03:50 PM, Gena Makhomed wrote:
On 30.12.2015 16:51, Jim Popovitch wrote:
On Dec 30, 2015 8:46 AM, "Gena Makhomed" <gmm at<mailto:gmm at>> wrote:
Workaround of race condition between systemd and nginx.

Just replace with in systemd unit
More details:

From that page, wrt

"It is strongly recommended not to pull in this target too liberally: for
example network server software should generally not pull this in (since
server software generally is happy to accept local connections even before
any routable network interface is up), it's primary purpose is network
client software that cannot operate without network"
nginx now requires configured and up network, before starting daemon.
Replace with is easy workaround.

Actually it does not require that at all.

It would be more helpful if you posted your config files, but from your
log file i gather they look something like:

server {

And that, due to using systemd, the nginx service gets started before
the network-interface have been configured with the IP address shown.

Two ways you can work around this issue comes to mind.

1) Allow non-local binds

# echo 1 > /proc/sys/net/ipv4/ip_nonlocal_bind

Put 'net.ipv4.ip_nonlocal_bind = 1' in /etc/sysctl.conf to make it stick.

2) Configure nginx to listen to *:80

Add this to your config files somewhere.

server {
listen 80;

to your config files somewhere, and nginx will listen to
instead of every IP address you mention.

Hope that helps,

Daniel K.

nginx-devel mailing list
nginx-devel at<mailto:nginx-devel at>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx-devel mailing list