I think i am affected by the problem as well. I am currently running
Ubuntu 24.04.4 LTS and have unattended-upgrades enabled.

The recent case was after todays security updates, i will try to provide
the relvant logfiles. As far as i understand the case, nginx will get
restarted, but then systemd reexecutes and manages to start nginx a few
milliseconds after systemd-networkd has set up the network, nginx will
then fail to start.

/var/log/unattended-upgrades/unattended-upgrades-dpkg.log:
--
Log started: 2026-08-28  06:31:00
(Reading database ...  100%^M^M(Reading database ... 146708 files and 
directories currently installed.)
Preparing to unpack .../libp11-kit0_0.25.3-4ubuntu2.2_amd64.deb ...
Unpacking libp11-kit0:amd64 (0.25.3-4ubuntu2.2) over (0.25.3-4ubuntu2.1) ...
Setting up libp11-kit0:amd64 (0.25.3-4ubuntu2.2) ...
Processing triggers for libc-bin (2.39-0ubuntu8.8) ...

Running kernel seems to be up-to-date.

Restarting services...
 systemctl restart packagekit.service php8.3-fpm.service

Service restarts being deferred:
 systemctl restart systemd-logind.service

No containers need to be restarted.

User sessions running outdated binaries:
 db-import @ session #943: sshd[411224]
 db-import @ user manager service: systemd[5929]

No VM guests are running outdated hypervisor (qemu) binaries on this host.
Log ended: 2026-08-28  06:31:05
--

systemd journal (only relevant lines):
--
Aug 28 06:30:28.070721 dtm-www systemd[1]: Starting apt-daily-upgrade.service - 
Daily apt upgrade and clean activities...
Aug 28 06:30:36.153909 dtm-www apt.systemd.daily[413236]: 
/usr/bin/unattended-upgrade:567: DeprecationWarning: This process (pid=413236) 
is multi-threaded, use of fork() may lead to deadl>
Aug 28 06:30:36.153909 dtm-www apt.systemd.daily[413236]:   pid = os.fork()
Aug 28 06:30:42.799998 dtm-www dbus-daemon[1131]: [system] Activating via 
systemd: service name='org.freedesktop.PackageKit' unit='packagekit.service' 
requested by ':1.44124' (uid=0 pid=4>
Aug 28 06:30:42.811235 dtm-www systemd[1]: Starting packagekit.service - 
PackageKit Daemon...
Aug 28 06:30:42.817344 dtm-www PackageKit[413448]: daemon start
(...)
Aug 28 06:30:44.566138 dtm-www systemd[1]: Stopping nginx.service - A high 
performance web server and a reverse proxy server...
Aug 28 06:30:44.629629 dtm-www systemd[1]: nginx.service: Deactivated 
successfully.
Aug 28 06:30:44.630064 dtm-www systemd[1]: Stopped nginx.service - A high 
performance web server and a reverse proxy server.
Aug 28 06:30:44.630163 dtm-www systemd[1]: nginx.service: Consumed 1min 10.060s 
CPU time, 505.5M memory peak, 0B memory swap peak.
Aug 28 06:30:44.645258 dtm-www systemd[1]: Starting nginx.service - A high 
performance web server and a reverse proxy server...
Aug 28 06:30:44.692734 dtm-www nginx[413477]: 2026/08/28 06:30:44 [info] 
413477#413477: Using 116KiB of shared memory for nchan in 
/etc/nginx/nginx.conf:69
Aug 28 06:30:44.692734 dtm-www nginx[413477]: 2026/08/28 06:30:44 [info] 
413477#413477: Using 131072KiB of shared memory for nchan in 
/etc/nginx/nginx.conf:69
Aug 28 06:30:44.772534 dtm-www systemd[1]: Started nginx.service - A high 
performance web server and a reverse proxy server.
(...)
Aug 28 06:30:49.289041 dtm-www systemd[1]: Reloading requested from client PID 
413641 ('systemctl') (unit apt-daily-upgrade.service)...
Aug 28 06:30:49.289096 dtm-www systemd[1]: Reloading...
Aug 28 06:30:50.392622 dtm-www systemd[1]: [🡕] 
/etc/systemd/system/[email protected]:6: Special user nobody configured, this is 
not safe!
Aug 28 06:30:50.668047 dtm-www systemd[1]: Reloading finished in 1378 ms.
Aug 28 06:30:55.945796 dtm-www systemd[1]: Reexecuting requested from client 
PID 413812 ('systemctl') (unit apt-daily-upgrade.service)...
Aug 28 06:30:55.952442 dtm-www systemd[1]: Reexecuting.
Aug 28 06:30:56.024890 dtm-www systemd[1]: systemd 255.4-1ubuntu8.17 running in 
system mode (+PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT 
-GNUTLS +OPENSSL +ACL +BLKID +>
Aug 28 06:30:56.025015 dtm-www systemd[1]: Detected virtualization kvm.
Aug 28 06:30:56.025078 dtm-www systemd[1]: Detected architecture x86-64.
(...)
Aug 28 06:30:57.456127 dtm-www systemd[1]: Stopping nginx.service - A high 
performance web server and a reverse proxy server...
Aug 28 06:30:57.458443 dtm-www sshd[307228]: Received signal 15; terminating.
Aug 28 06:30:57.458580 dtm-www systemd[1]: Stopping ssh.service - OpenBSD 
Secure Shell server...
Aug 28 06:30:57.665100 dtm-www systemd[1]: 
systemd-networkd-wait-online.service: Deactivated successfully.
Aug 28 06:30:57.665154 dtm-www systemd[1]: Stopped 
systemd-networkd-wait-online.service - Wait for Network to be Configured.
Aug 28 06:30:57.665187 dtm-www systemd[1]: Stopping 
systemd-networkd-wait-online.service - Wait for Network to be Configured...
Aug 28 06:30:57.665210 dtm-www systemd[1]: Stopping systemd-networkd.service - 
Network Configuration...
Aug 28 06:30:57.665309 dtm-www systemd[1]: Stopping systemd-resolved.service - 
Network Name Resolution...
Aug 28 06:30:57.665366 dtm-www systemd[1]: Stopping systemd-timesyncd.service - 
Network Time Synchronization...
Aug 28 06:30:57.665462 dtm-www systemd[1]: nginx.service: Deactivated 
successfully.
Aug 28 06:30:57.665505 dtm-www systemd[1]: Stopped nginx.service - A high 
performance web server and a reverse proxy server.
Aug 28 06:30:57.665530 dtm-www systemd[1]: systemd-timesyncd.service: 
Deactivated successfully.
Aug 28 06:30:57.665576 dtm-www systemd[1]: Stopped systemd-timesyncd.service - 
Network Time Synchronization.
Aug 28 06:30:57.665617 dtm-www systemd[1]: systemd-resolved.service: 
Deactivated successfully.
Aug 28 06:30:57.665668 dtm-www systemd[1]: Stopped systemd-resolved.service - 
Network Name Resolution.
Aug 28 06:30:57.665720 dtm-www systemd[1]: systemd-resolved.service: Consumed 
28.935s CPU time, 3.9M memory peak, 0B memory swap peak.
Aug 28 06:30:57.665771 dtm-www systemd[1]: Started ssh.service - OpenBSD Secure 
Shell server.
Aug 28 06:30:57.665789 dtm-www systemd[1]: Starting nginx.service - A high 
performance web server and a reverse proxy server...
Aug 28 06:30:57.665991 dtm-www systemd[1]: Starting systemd-resolved.service - 
Network Name Resolution...
Aug 28 06:30:57.666009 dtm-www systemd[1]: Starting systemd-timesyncd.service - 
Network Time Synchronization...
Aug 28 06:30:57.666046 dtm-www systemd[1]: systemd-networkd.service: 
Deactivated successfully.
Aug 28 06:30:57.666069 dtm-www systemd[1]: Stopped systemd-networkd.service - 
Network Configuration.
Aug 28 06:30:57.666099 dtm-www systemd[1]: Starting systemd-networkd.service - 
Network Configuration...
Aug 28 06:30:57.666117 dtm-www systemd[1]: nginx.service: Control process 
exited, code=exited, status=1/FAILURE
Aug 28 06:30:57.666146 dtm-www systemd[1]: nginx.service: Failed with result 
'exit-code'.
Aug 28 06:30:57.666171 dtm-www systemd[1]: Failed to start nginx.service - A 
high performance web server and a reverse proxy server.
Aug 28 06:30:57.666193 dtm-www systemd[1]: systemd-journald.service: 
Deactivated successfully.
Aug 28 06:30:57.666207 dtm-www systemd[1]: Stopped systemd-journald.service - 
Journal Service.
Aug 28 06:30:57.666228 dtm-www systemd[1]: systemd-journald.service: Consumed 
5.059s CPU time, 10.4M memory peak, 0B memory swap peak.
Aug 28 06:30:57.666260 dtm-www systemd[1]: Starting systemd-journald.service - 
Journal Service...
Aug 28 06:30:57.666278 dtm-www systemd[1]: Started systemd-timesyncd.service - 
Network Time Synchronization.
Aug 28 06:30:57.666348 dtm-www systemd[1]: Started systemd-networkd.service - 
Network Configuration.
Aug 28 06:30:57.666393 dtm-www systemd[1]: Starting 
systemd-networkd-wait-online.service - Wait for Network to be Configured...
Aug 28 06:30:57.666928 dtm-www systemd[1]: Started systemd-resolved.service - 
Network Name Resolution.
Aug 28 06:30:57.486915 dtm-www systemd-networkd[307304]: Restart operation 
initiated.
Aug 28 06:30:57.519388 dtm-www sshd[413891]: Server listening on 0.0.0.0 port 
22.
Aug 28 06:30:57.671164 dtm-www systemd[1]: Started systemd-journald.service - 
Journal Service.
Aug 28 06:30:57.486930 dtm-www systemd-networkd[307304]: Bus bus-api-network: 
changing state RUNNING → CLOSED
(...)
Aug 28 06:30:57.672815 dtm-www nginx[413901]: 2026/08/28 06:30:57 [emerg] 
413901#413901: host not found in upstream "example.com" in 
/etc/nginx/sites-enabled/example.com:69
Aug 28 06:30:57.672815 dtm-www nginx[413901]: nginx: configuration file 
/etc/nginx/nginx.conf test failed
Aug 28 06:30:57.513978 dtm-www systemd-networkd[307304]: Serializing...
Aug 28 06:30:57.514003 dtm-www systemd-networkd[307304]: ens3: Serializing 
static address (configured): 192.168.89.107/24 broadcast 192.168.89.255 (valid 
forever, preferred forever), flags: permanent, scope: global, label: n/a
(...)
Aug 28 06:30:57.680484 dtm-www systemd[1]: Finished 
systemd-networkd-wait-online.service - Wait for Network to be Configured.
(...)
Aug 28 06:31:06.879512 dtm-www systemd[1]: apt-daily-upgrade.service: 
Deactivated successfully.
Aug 28 06:31:06.879939 dtm-www systemd[1]: Finished apt-daily-upgrade.service - 
Daily apt upgrade and clean activities.
Aug 28 06:31:06.880264 dtm-www systemd[1]: apt-daily-upgrade.service: Consumed 
29.237s CPU time, 490.5M memory peak, 0B memory swap peak.
--

I dont think that excluding nginx from being automatically restarted
will fix this problem, since its the restart of systemd that triggers
that behaviour. Is there any way to work around this behaviour?

Thank you,
Michael

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2051766

Title:
  needrestart should priorize and wait for network and DNS when
  restarting services

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/needrestart/+bug/2051766/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to