Apache automatically stopped working while the server is running

Hello HestiaCP Community,

I have 2 servers running with HestiaCP.
I have setup many servers using HestiaCP, But I am facing a problem with two of them with Apache where it stops working for no apparent reason and without modifying the server.

It simply works without a problem when trying to start it from the services page in HestiaCP.

Also when rebooting the server it does not work automatically, But has to be started manually each time.
Is there an explanation for this situation?

Hi @MR.Dev

I hope it is in the logs:

journalctl -u apache2.service -b --no-pager -l

Maybe the ip and its interface is not ready when apache tries to start…

Hi @sahsanu
Thank you for your answer.
root@games /var/log/hestia # journalctl -u apache2.service -b --no-pager -l
– Logs begin at Wed 2024-07-10 11:45:47 +03, end at Sat 2024-11-09 19:43:08 +03. –
Nov 09 17:50:05 games.domain.com systemd[1]: Starting The Apache HTTP Server…
Nov 09 17:50:05 games.domain.com apachectl[771]: (99)Cannot assign requested address: AH00072: make_sock: could not bind to address ServerIP:8443
Nov 09 17:50:05 games.domain.com apachectl[771]: no listening sockets available, shutting down
Nov 09 17:50:05 games.domain.com apachectl[771]: AH00015: Unable to open logs
Nov 09 17:50:05 games.domain.com systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
Nov 09 17:50:05 games.domain.com systemd[1]: apache2.service: Failed with result ‘exit-code’.
Nov 09 17:50:05 games.domain.com systemd[1]: Failed to start The Apache HTTP Server.
Nov 09 17:52:46 games.domain.com systemd[1]: Starting The Apache HTTP Server…
Nov 09 17:52:46 games.domain.com systemd[1]: Started The Apache HTTP Server.

As I commented, the ip is not available when Apache starts.

Show the output:

systemctl cat apache2

@sahsanu
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=Apache HTTP Server Version 2.4 Documentation - Apache HTTP Server Version 2.4

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

[Install]
WantedBy=multi-user.target

Try this:

systemctl edit apache2

Here add these lines:

[Unit]
After=network-online.target
Wants=network-online.target

In context:

### Editing /etc/systemd/system/apache2.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file

[Unit]
After=network-online.target
Wants=network-online.target

### Lines below this comment will be discarded

### /lib/systemd/system/apache2.service
[...]

Save the file and once done.

systemctl daemon-reload

And try again rebooting your server.

1 Like

Thank you,
I have add this and rebooted the server the server Apache is working automatically.
I will see if it will fail to restart in the coming days or not.

2 Likes