Apache (httpd) Fails To Start At Boot – CentOS 8.1

Home » CentOS » Apache (httpd) Fails To Start At Boot – CentOS 8.1
CentOS 11 Comments

If I do ‘systemctl start httpd’, apache will start right up. But during boot, it doesn’t and I
get the resulting errors below.

Jun 15 21:17:28 dream httpd[1534]: (99)Cannot assign requested address: AH00072: make_sock: could not bind to address 10.20.30.11:80
Jun 15 21:17:28 dream httpd[1534]: no listening sockets available, shutting down Jun 15 21:17:28 dream httpd[1534]: AH00015: Unable to open logs Jun 15 21:17:29 dream systemd[1]: httpd.service: Main process exited, code=exited, status=1/FAILURE
Jun 15 21:17:29 dream systemd[1]: httpd.service: Failed with result ‘exit-code’.

the box’s ip address is 10.20.30.11, and I am trying to get http (80), and https (443) going.

Firewall is turned on. The listen parameter in httpd.conf is 10.20.30.11:80 The log files in
/var/log/httpd are all owned by root. Httpd runs as user ‘apache’.

Google searches have not returned anything that looks remotely promising.

Got any suggestions?

Thanks in advance,

Jay

11 thoughts on - Apache (httpd) Fails To Start At Boot – CentOS 8.1

  • I have always had exactly the same problem. I had to write a script and run it at boot time:

    sleep 10
    /usr/bin/systemctl start httpd

    Must be some timing problem with the interface addresses not being set up in time.

    Alan

  • Could some transient service be holding port 80 at that time?

    You could probably arrange to run a script that runs “lsof -i” and “ip addr show”, dumping the output to a temp file, just before httpd runs to see what’s not set up right.

  • httpd is starting before an interface has been configured with 10.20.30.11.

    The default configuration starts httpd after “network.target” but you want to start it after “network-online.target”.

    IIRC: run “systemctl edit httpd.service” and insert:

    [Unit]
    After=network-online.target

  • Il 16/06/20 08:11, Alessandro Baggi ha scritto:

    Note: when you will get update for httpd package all could be reverted to the original status, so to avoid that your modified httpd.service will get an overwrite, create an alternative httpd.service in
    /etc/systemd/system (if I’m not wrong).

    Probably there is a new way to do this.

  • That’s half right now, but still not good enough. If the RPM provided file changes, your copy won’t get those changes. To make this work better, don’t put the full file in /etc/systemd/system but just add an override.conf there which is like a diff to the original file. That way updates of the RPM are handled correctly.

    Simon

  • Just a wild guess, but it sounds like Apache is being started before the network is online. Is this host simple static Ethernet or DHCP, or is it something more complicated like WiFi?

    I believe you can set service dependencies with systemd, ideally your apache service isn’t started before the network is online.

    If you are using WiFi, running a webserver is a bit ugly, perhaps configuring Apache to listen to 0.0.0.0 (all interfaces) would be a better choice?

  • The new way to do this is exactly what Gordon suggested – using
    `systemctl edit ` creates an override in
    `/etc/systemd/system/httpd.service.d/override.conf`.

    The only issue is that there is no `systemctl` related command to remove this override – you will have to remember to `rm -rf
    /etc/systemd/system/httpd.service.d` if/when you want to remove that override.

  • Thanks to all that responded. Gordon’s suggestion worked brilliantly. I ran the suggested command, saved the file, rebooted, apache came right up.

    Can’t thank you guys enough.

    Now, lets try to solve my intermittent connectivity issue, more on that later…

    Jay

  • Let me educate myself – `systemctl revert ` is the correct way to remove an override.

    * I learn something new everyday…