Score:0

Apache2 won't start even with unit file update post reboot

cc flag

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

Appreciate any inputs on the matter

Environment : Ubuntu 20.04.2 LTS + Apache/2.4.41

vidarlo avatar
ar flag
It says it can't bind to one of the addresses specified. Is network properly up by the time you attempt to bind?
ardv avatar
cc flag
This part i'm not sure, so that's why I added the `After=network.target network-online.target` but even after adding that when I test restart apache still can't automatically start post reboot. Is there any other way to add dependency to Apache2 so that it won't try to start before the network has properly come up?
in flag
Is Port 80 available? Check if it is not in use by another process `ss -tnlp |grep :80`.
ardv avatar
cc flag
yep, when i do that after a restart there's no output. After I start apache2 manually it then gives me the ipv4 and ipv6 entries that are listening to it.
I sit in a Tesla and translated this thread with Ai:

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.