Today unattended-upgrades upgraded libc6 and restarted all services using it.
I don’t want to discuss whether unattended-upgrades should or should not restart services, I will go with whatever Ubuntu 24.04’s default behavior is.
I just want to initiate a discussion on how to prevent nginx from failing to restart again.
This is what happened:
# tail /var/log/apt/history.log
Start-Date: 2025-09-23 06:09:19
Commandline: /usr/bin/unattended-upgrade
Upgrade: libc6:amd64 (2.39-0ubuntu8.5, 2.39-0ubuntu8.6), locales:amd64 (2.39-0ubuntu8.5, 2.39-0ubuntu8.6), libc-dev-bin:amd64 (2.39-0ubuntu8.5, 2.39-0ubuntu8.6), libc-bin:amd64 (2.39-0ubuntu8.5, 2.39-0ubuntu8.6), libc-devtools:amd64 (2.39-0ubuntu8.5, 2.39-0ubuntu8.6), libc6-dev:amd64 (2.39-0ubuntu8.5, 2.39-0ubuntu8.6)
End-Date: 2025-09-23 06:09:31
Needrestart triggered service restarts
# less /var/log/unattended-upgrades/unattended-upgrades-dpkg.log
Restarting services...
/etc/needrestart/restart.d/systemd-manager
systemctl restart cron.service nginx.service ssh.service systemd-journald.service systemd-resolved.service
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.
nginx failed to restart with this error
# systemctl status nginx.service
× nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Tue 2025-09-23 06:09:12 CEST; 2h 9min ago
Duration: 6d 11h 15min 10.745s
Docs: man:nginx(8)
CPU: 53ms
Sep 23 06:09:12 server nginx[2416442]: 2025/09/23 06:09:12 [emerg] 2416442#2416442: host not found in upstream "ec2-3-120-6-158.eu-central-1.compute.amazonaws.com:8000" in /etc/nginx/sites->
Sep 23 06:09:12 server nginx[2416442]: nginx: configuration file /etc/nginx/nginx.conf test failed
Sep 23 06:09:12 server systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Sep 23 06:09:12 server systemd[1]: nginx.service: Failed with result 'exit-code'.
Sep 23 06:09:12 server systemd[1]: Failed to start nginx.service - A high performance web server and a reverse proxy server.
The upstream host DOES EXIST and IS RESOLVABLE.
The problem was, I assume, that systemd-resolved.service and nginx.service were restarted at the same time.
The fix, in this case, was easy, I just restarted nginx manually while systemd-resolved was running.
Unfortunately this caused production outage, not mentioning that all our maxscale, elasticsearch, mariadb, keepalived, etc… services were restarted as well. I am not going to comment on that, and I am glad we have not migrated our RabbitMQ cluster to Ubuntu 24.04 yet…
Since Ubuntu 24.04 defaulted to restarting all affected services after unattended-upgrade does a library upgrade, is it at least possible to restart them one by one? Or restart all systemd- services prior the non-systemd services?
Thanks,
Oskar