Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#1028155: nginx-common: nginx fails to start on reboot when IPv6 enabled.

69 views
Skip to first unread message

LeJacq, Jean Pierre

unread,
Jan 7, 2023, 4:40:05 PM1/7/23
to
Package: nginx-common
Version: 1.22.1-5
Severity: normal

Dear Maintainer,

* What led up to the situation?

I have a dual IPv4/IPv6 server with nginx listening on both with the following directive:

server
{
server_name "example.org";
listen 144.202.24.41:443 default_server ssl http2;
listen [2001:19f0:5401:58:5400:3ff:fe59:e2b1]:443 default_server ssl http2;

...
}

When I reboot the server and login, systemctl report the following:

$ systemctl status nginx.service
× nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Sat 2023-01-07 16:17:40 EST; 50s ago
Docs: man:nginx(8)
Process: 481 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
CPU: 49ms

Jan 07 16:17:40 lj01 systemd[1]: Starting A high performance web server and a reverse proxy server...
Jan 07 16:17:40 lj01 nginx[481]: nginx: [emerg] bind() to [2001:19f0:5401:58:5400:3ff:fe59:e2b1]:443 failed (99: Cannot assign requested address)
Jan 07 16:17:40 lj01 nginx[481]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jan 07 16:17:40 lj01 systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Jan 07 16:17:40 lj01 systemd[1]: nginx.service: Failed with result 'exit-code'.
Jan 07 16:17:40 lj01 systemd[1]: Failed to start A high performance web server and a reverse proxy server.

* What exactly did you do (or not do) that was effective (or
ineffective)?

Restarting the nginx service resolves the issue.

This appears to be a dependency issue in the nginx.service file.

-- System Information:
Debian Release: 11.4 (Qinux 3.2)
APT prefers stable-security
APT policy: (1000, 'stable-security'), (1000, 'stable'), (500, 'stable-updates'), (100, 'bullseye-fasttrack'), (100, 'bullseye-backports-staging'), (100, 'unstable'), (10, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 6.0.0-0.deb11.6-amd64 (SMP w/12 CPU threads; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Thank you for using reportbug

--
JP
signature.asc

LeJacq, Jean Pierre

unread,
Jan 19, 2023, 7:20:04 AM1/19/23
to
Tags: fixed ipv6

While nginx has not changed and I have not changed my nginx configuration,
nginx now comes up successfully on reboot.

thanks

--
JP
signature.asc

LeJacq, Jean Pierre

unread,
Jan 25, 2023, 6:40:06 AM1/25/23
to
On Thursday, January 19, 2023 7:11:49 AM EST LeJacq, Jean Pierre wrote

This problem reoccurred after updates to my system, none related to nginx.

It appears to be an ordering or race condition in the startup scripts.

thanks

--
JP
signature.asc

LeJacq, Jean Pierre

unread,
Mar 11, 2023, 8:00:05 PM3/11/23
to
The core issue is that the nginx is starting before the IPv6 address is bound.

systemd-networkd has a specific service, systemd-networkd-wait-online.service,
that will force all online services to wait until the network interfaces are
configured.

After switching to systemd-networkd from ifupdown, nginx now comes up
reliably.

I'm not sure if this is a bug in nginx. It may be worth an addition to the
documentation about this potential issue.

--
JP
signature.asc

Perlover

unread,
Aug 4, 2023, 12:00:04 PM8/4/23
to
Hello,

I know what the problem is.

The problem is that nginx starts before all network interfaces are upped
up. I looked through all nginx unit files (nginx-common debian package)
and found that all versions, including Ubuntu 22.04, have incorrect
After & Wants.

All versions from the package specify After=network.target, but if you
study this network.target, it does not guarantee that the entire network
on the device is already configured. It is correct to use
network-online.target. Moreover, it is also recommended by the nginx
developers themselves:

https://www.nginx.com/resources/wiki/start/topics/examples/systemd/

As a temporary solution, I recommend doing so until it is fixed in the
package nginx-common itself:

$ sudo systemctl edit nginx.service

To insert there:

[Unit]
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

Best regards, Perlover
0 new messages