1

Issue : after server reboot apache2 won't automatically start (have to manually ssh and start via systemctl which starts without any issue)

Error message:

Feb 08 05:53:46 domain1_test.com systemd[1]: Starting The Apache HTTP Server...
Feb 08 05:53:47 domain1_test.com apachectl[834]: (99)Cannot assign requested address: AH00072: make_sock: could not bind to address [xxxx:xxxx::xxxx:xxxx:xxxx:xxxx]:80
Feb 08 05:53:47 domain1_test.com apachectl[834]: no listening sockets available, shutting down
Feb 08 05:53:47 domain1_test.com apachectl[834]: AH00015: Unable to open logs
Feb 08 05:53:47 domain1_test.com apachectl[809]: Action 'start' failed.
Feb 08 05:53:47 domain1_test.com apachectl[809]: The Apache error log may have more information.
Feb 08 05:53:47 domain1_test.com systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
Feb 08 05:53:47 domain1_test.com systemd[1]: apache2.service: Failed with result 'exit-code'.

Current apache setup :

# port.conf
Listen xxx.xxx.xx.xx:80
Listen xxx.xxx.xx.xx:443

Listen [xxxx:xxxx::xxxx:xxxx:xxxx:xxxx]:80
Listen [xxxx:xxxx::xxxx:xxxx:xxxx:xxxx]:443

---

# domain1_VirtualHosts.conf
<VirtualHost xxx.xxx.xx.xx:80 [xxxx:xxxx::xxxx:xxxx:xxxx:xxxx]:80>
....
<VirtualHost xxx.xxx.xx.xx:443 [xxxx:xxxx::xxxx:xxxx:xxxx:xxxx]:443>

I have already tested adding network dependency through target and wants in the apache2 unit file but still getting the cannot bind socket error upon checking on the apache2 status post reboot

[Unit]
Description=The Apache HTTP Server
After=network.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
Documentation=https://httpd.apache.org/docs/2.4/

[Service]
Type=forking
Environment=APACHE_STARTED_BY_SYSTEMD=true
ExecStart=/usr/sbin/apachectl start
ExecStop=/usr/sbin/apachectl stop
ExecReload=/usr/sbin/apachectl graceful
PrivateTmp=true
Restart=on-abort

[Install]
WantedBy=multi-user.target

Environment :

  • Linode
  • Ubuntu 20.04.2 LTS
  • Apache/2.4.41
  • VirtualMin/webmin

Interface conf:

iface eth0 inet dhcp

iface eth0 inet6 manual
        pre-up /sbin/modprobe -q ipv6 ; /bin/true

systemd network conf:

[Match]
Name=eth0

[Network]
DHCP=no
DNS=xxx.x.xx.xx xxx.xxx.xx.x xxx.xxx.xx.x
Domains=members.linode.com
IPv6PrivacyExtensions=false

Gateway=xxx.xxx.xx.x
Address=xxx.xxx.xx.xx/24

Appreciate any inputs on the matter 🙏

2
  • You've not said how the IPv6 address is being applied. Is it static? Is it dhcpv6? Is it autoconf? Seems to be clear though that the system has not yet applied the IPv6 address to the interface, you'll need to investigate why.
    – Bib
    Feb 9, 2023 at 14:07
  • Thank you very much for the information! However I'm not yet 100% sure as I am new to this. I believe LInode automatically configures it via ipv6 slaac, but then again on the interfaces conf i see it set to manual and on systemd/network i don't see any explicit entry for ipv6. updating question with more info
    – ardv
    Feb 9, 2023 at 23:34

1 Answer 1

0

This is caused by a delay in the interface getting an IPv6 address. One solution would be to call a ExecStartPre= script in the service file which will go through a tight loop checking if it has been supplied. Such as (change as required):

#!/bin/sh

for Secs in {1..60}
do
        ip addr show dev eth0 | grep -qi <IPv6 address> && echo Found in ${Secs} &&  exit 0
        sleep 1
done

echo "NOT FOUND after ${Secs} seconds"
exit 1 

I have tested that the script works, just not within the service file.

2
  • Thank you very much! You are right, i think there's a delay from SLAAC config for the Ipv6 and DAD, however i'm not able to get the snippet working :( for some reason sleep isn't working on the executable script executed by ExecStartPre so for now i have settled on ExecStartPre=/bin/sleep 10 but still curious as to how to make the script work tho 😅
    – ardv
    Feb 11, 2023 at 8:52
  • Was able to make the snippet work and tested with a restart, it did find the ipv6 entry in 3 seconds however it gave the same error apachectl[1275]: (99)Cannot assign requested address: AH00072: make_sock: could not bind to address [xxxx:xxxx::xxxx:xxxx:xxxx:xxxx]:80
    – ardv
    Feb 11, 2023 at 9:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .