Starting point:
My system (Ubuntu 18.04.1) is a VPS running on KVM. The network with some additional IPs is configured with Netplan.
Problem:
The Apache server is running on an additional IP. If the VPS reboots, the apache didn’t start because, it couldn’t be bind on an aditional IP. A log entry like the following can be found:
apachectl[631]: (99)Cannot assign requested address: AH00072: make_sock: could not bind to address [xxxxxxxx]:80
But if you restart Apache after the reboot, it runs as expected!
Strange, isn’t it?
Solution:
Ok, I couldn’t find the exact reason of this reason. But I think, there is a strange timing issue on reboot. The network isn’t completely up before Apache is starting.
To solve the problem, just edited the section ‘Unit’ in the file /lib/systemd/system/apache2.service and replace
After=network.target remote-fs.target nss-lookup.target
with
Requires=network-online.target After=network-online.target remote-fs.target nss-lookup.target
That’s it!
More information about the network-target can be found her: https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/