Score:0

Apache 2.4.41 tries to bind all interfaces on boot - but works fine if I start by service

nu flag

The title says it all. My problem: I reboot my server and Apache is dead, websites are down. Seems like Apache is trying to bind on all IPs... but why?

If I check why, by issuing: service apache2 status

● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2021-12-15 00:25:19 CET; 18s ago
       Docs: https://httpd.apache.org/docs/2.4/

Dec 15 00:25:19 y systemd[1]: Starting The Apache HTTP Server...
Dec 15 00:25:19 y apachectl[563]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using [ipv6 addr]. Set the 'ServerN>
Dec 15 00:25:19 y apachectl[563]: (99)Cannot assign requested address: AH00072: make_sock: could not bind to address 1.2.3.4:80
Dec 15 00:25:19 y apachectl[563]: no listening sockets available, shutting down
Dec 15 00:25:19 y apachectl[563]: AH00015: Unable to open logs
Dec 15 00:25:19 y apachectl[549]: Action 'start' failed.
Dec 15 00:25:19 y apachectl[549]: The Apache error log may have more information.
Dec 15 00:25:19 y systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
Dec 15 00:25:19 y systemd[1]: apache2.service: Failed with result 'exit-code'.
Dec 15 00:25:19 y systemd[1]: Failed to start The Apache HTTP Server.
  • OS is a bone-stock Ubuntu 20.04.3 LTS running on a server.
  • The server has two (ipv4) IPs and I want Apache to only bind to 1 ipv4.

/etc/apache2/ports.conf contains only this:

Listen 1.2.3.4:80
<IfModule ssl_module>
        Listen 1.2.3.4:443
</IfModule>

<IfModule mod_gnutls.c>
        Listen 1.2.3.4:443
</IfModule>

Each VirtualHost only contains:

<VirtualHost *:80>
</VirtualHost>

And a separate config for SSL (auto-created by Certbot ACME).

Apache avatar
nu flag
So obviously, the `service apache2 restart` (which works) is different, than the service that gets called on boot. But why?
in flag
Is there anything in `/var/log/apache2/error.log` to better explain the issue? It may also be worth while to look at `/var/log/syslog` to see if Apache is starting before the network interfaces are up, which would certainly cause this sort of issue.
Score:0
nu flag

Apparently, this is a new bug/issue regarding Mailcow, or it's related to networking if you have multiple IPs on the interface. On Ubuntu 18.04, it's Netplan. (So basically I can't pinpoint the culprit for now.)

Anyway. Here is the workaround (kudos to Michael).
In /etc/sysctl.conf, add these lines to the end:

net.ipv4.ip_nonlocal_bind=1
net.ipv6.ip_nonlocal_bind=1

See docs.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.