Cannot start Nginx

Operating system Ubuntu Linux 24.04.1
Webmin version 2.202 Usermin version 2.102
Virtualmin version 7.20.2 Authentic theme version 21.20.7

My webserver was sometimes working upon reboot, and then sometimes not, and now just not with the current errors:

From Journalctl

Nov 03 20:53:13 host5.johnsimmonshypertext.com nginx[1351]: nginx: [emerg] bind(
) to [2604:180:f4::30d]:443 failed (99: Cannot assign requested address)
Nov 03 20:53:13 host5.johnsimmonshypertext.com nginx[1351]: nginx: configuration
 file /etc/nginx/nginx.conf test failed
Nov 03 20:53:13 host5.johnsimmonshypertext.com systemd[1]: nginx.service: Contro
l process exited, code=exited, status=1/FAILURE

From trying to save an nginx conf that I didn’t actually change:

Failed to save configuration file : Configuration is invalid : nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: [emerg] bind() to [2604:180:f4::30d]:443 failed (99: Cannot assign requested address) nginx: configuration file /etc/nginx/nginx.conf test failed 

Nginx is seeming a bit brittle, but I would like to solve issues.

TIA,

John

The issue appears to be similar to

The solution to that one is the first thing I checked. It’s not the same issue though.

In this instance too it appears that the issue is related to binding - of the port 443 on your ipv6 address.

Are you certain that you have no Apache pollution on one of the webservers. (a simple .htaccess file that is being called/updated by a program/module on the webserver could do it - it can elevate a bug in the website to seem to be an nginx bug) - so has something changed on one of the websites?

I ensure that ALL .htaccess files are removed from websites (nginx does not need them).

I think they are long gone, but I will do a check. I actually broke down and rebuilt the server and restored virtual servers from backups. This is the point I had gotten to before, and then I started doing some performance tuning of PHP directives, when everything broke. I’m going to put off doing that until I have some time. Everything is back up and running, but I am concerned with how brittle Nginx seems to be. If/When I break it again, I’ll start a new thread.

If you configure or install anything which grabs ports 80 and 443 before Nginx does then it will throw that error. It’s very brittle in that way.

I just rebooted, and Nginx refuses to come up. There were no changes to configuration files. If I simply open /etc/nginx/nginx.conf, and try to save it without changing anything, I get the error:

Failed to save configuration file : Configuration is invalid : nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx.

nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] bind() to [2604:180:f4::30d]:443 failed (99: Cannot assign requested address)
nginx: configuration file /etc/nginx/nginx.conf test failed

ss -ltpn |grep :443 - nothing running

In /usr/lib/systemd/system/nginx.service, the following lines:

[Unit]
Description=A high performance web server and a reverse proxy server
Documentation=man:nginx(8)
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

This should prevent Nginx from trying to start before the network is up.

OK, so I just rebooted one more time, and this time nginx came up. WTF?
No problem identified or solved.