Httpd fails after reboot but can be manually started

I’m setting up my first rocky9 box. After configuring httpd.conf and ssl.conf, like I did on a rocky8 box, I can start and enable httpd with systemctl and the website works in the browser, but after a reboot httpd fails to start. This is the httpd status after reboot. Since my configuration steps work for rocky8, has something changed in rocky9 that needs configuration?

systemctl status httpd
 httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/httpd.service.d
             └─php-fpm.conf
     Active: failed (Result: exit-code) since Wed 2025-08-27 18:28:43 PDT; 1min 45s ago
       Docs: man:httpd.service(8)
   Main PID: 837 (code=exited, status=1/FAILURE)
     Status: "Reading configuration..."
        CPU: 42ms

Aug 27 18:28:43 finaidtest systemd[1]: Starting The Apache HTTP Server...
Aug 27 18:28:43 finaidtest httpd[837]: AH00548: NameVirtualHost has no effect and will be removed i>
Aug 27 18:28:43 finaidtest httpd[837]: (99)Cannot assign requested address: AH00072: make_sock: cou>
Aug 27 18:28:43 finaidtest httpd[837]: no listening sockets available, shutting down
Aug 27 18:28:43 finaidtest httpd[837]: AH00015: Unable to open logs
Aug 27 18:28:43 finaidtest systemd[1]: httpd.service: Main process exited, code=exited, status=1/FA>
Aug 27 18:28:43 finaidtest systemd[1]: httpd.service: Failed with result 'exit-code'.
Aug 27 18:28:43 finaidtest systemd[1]: Failed to start The Apache HTTP Server.

I asked Google Gemini and it said this: “No listening sockets available” in an Apache HTTPD error log typically indicates that the web server can’t start or reload because another process is already using the port it’s configured to listen on, usually port 80 for HTTP or port 443 for HTTPS.

You might try these commands to see if something is indeed already listening:

sudo ss -tlnp

sudo netstat -tlnp

Hope that helps,

Tony

Results for the commands

ss -tlnp
State   Recv-Q  Send-Q   Local Address:Port      Peer Address:Port  Process
LISTEN  0       511    	 *:80                    *:*      			users:(("httpd",pid=3315,fd=4),))
LISTEN  0       511      *:443                   *:*      			users:(("httpd",pid=3315,fd=8),("httpd",pid=921,fd=8),)


netstat -tlnp
Proto      Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp6       0      0      :::80                   :::*                    LISTEN      847/httpd
tcp6       0      0      :::443                  :::*                    LISTEN      847/httpd

With my rocky8 box, I used the ip address on with Listen in httpd.conf. Using just Listen 80 fixed it. The rocky8 is a physical box while the rocky9 is a VM. I figured something with the VM is preventing httpd to start after reboot with an ip address on Listen.

First thing I noticed with your “netstat” output is that it only shows “tcp6” (IPv6) [for both output lines], I believe you should have “tcp” listed in the first column, if you are expecting web pages via IPv4? or maybe you can explain how you expect people to connect to your server?

It’s like that on most systems now. It shows :::80 but it’s still listening on ipv4, even if you don’t see it. Confusing yes :slight_smile:

root@rocky9:~# netstat -tunlp | grep httpd
tcp6       0      0 :::80                   :::*                    LISTEN      3024/httpd
root@rocky9:~# nc -zv localhost 80
Connection to localhost (::1) 80 port [tcp/http] succeeded!
root@rocky9:~# nc -zv 10.1.21.46 80
Connection to 10.1.21.46 80 port [tcp/http] succeeded!

so whilst the netstat/ss commands show what it does, it doesn’t necessarily mean it’s only available on ipv6.

Chances are when you put the IP address in the Apache config, the network wasn’t ready, and the IP wasn’t active when Apache started. That’s the only real explanation for it. You can edit the httpd.service to make sure it starts even later in the boot process. I’ve had to do something similar, but for a completely different service.

root@neotest:/etc/systemd/system# cat myservice.service 
[Unit]
Description=myservice
After=network-online.target

Note the difference here that httpd service will probably just have network.target. So you can add an additional After for network-online. Then your Apache config should allow the listen with the IP address as you had previously.

1 Like

Thanks for the insight. If httpd.service is not listed in my /etc/systemd/system directory, but found in /lib/systemd/system/, is this the same file to edit?

My httpd.service file already contains:

[Unit]
	Description=The Apache HTTP Server
	Wants=httpd-init.service
	After=network.target remote-fs.target nss-lookup.target httpd-init.service
	Documentation=man:httpd.service(8)

Since httpd-init.service is at the end of the After= line, do I just add network-online.target after the network.target entry or before the Wants=httpd-init.service?

You can have multiple After lines, or one single line. I don’t think the ordering matters too much as far as I’m aware, so it could look like this:

After=network.target network-online.target remote-fs.target nss-lookup.target httpd-init.service

or:

After=network.target remote-fs.target nss-lookup.target httpd-init.service
After=network-online.target
1 Like

Yes, but did you just blindly copy what you had on el8, or did you carefully check every line of the config to ensure it was properly set up for your new host?

For example, it gives a warning about a ‘NameVirtualHost’ being wrong, so who knows how messed up these config files are?

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.