2

Several time(twice or thrice) in a day, Apache gets automatically graceful restart and failed. My server is listening on port 81. When I checked its log it shows the error of port binding to 80 and unable to open log.

Each time after getting failed, I had to manually restart the service and then it starts working till the next.

My system is Ubuntu 16.04

The entry of log files /var/log/apache2/error.log:

[Fri Apr 17 04:27:50.713641 2020] [mpm_prefork:notice] [pid 7037] AH00171: Graceful restart requested, doing restart
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
[Fri Apr 17 04:27:50.842111 2020] [mpm_prefork:alert] [pid 7037] no listening sockets available, shutting down
[Fri Apr 17 04:27:50.842117 2020] [:emerg] [pid 7037] AH00019: Unable to open logs, exiting
[Fri Apr 17 04:28:16.608563 2020] [core:warn] [pid 14789] AH00098: pid file /var/run/apache2/apache2.pid overwritten -- Unclean shutdown of previous Apache run?
[Fri Apr 17 04:28:16.612506 2020] [mpm_prefork:notice] [pid 14789] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations
[Fri Apr 17 04:28:16.612538 2020] [core:notice] [pid 14789] AH00094: Command line: '/usr/sbin/apache2'
[Fri Apr 17 04:28:16.993356 2020] [mpm_prefork:notice] [pid 14789] AH00169: caught SIGTERM, shutting down
zero0
  • 21

1 Answers1

0

You'll need to figure out what is sending the graceful restart request. I had the exact same error and behavior and thought it was possibly log rotation, but that wasn't it. In my case it turned out to be Let's Encrypt's "Certbot".

I switched from using Certbot to refresh and update Apache, to using plain http on Apache and Caddy in front of it for SSL termination. So, I didn't need the Certbot/LE certs for Apache directly; however, after the Caddy config, Certbot wasn't able to re-verify and after the 30 days or so since last verification expired, Certbot started trying multiple times a day to refresh, giving up, but still trying to restart Apache, which for whatever reason it was unable to successfully do, causing this issue.

So, check if you have Certbot running (when you don't need it any longer). You can disable Certbot with the info here: How to completely remove "certbot" from ubuntu?

Artur Meinild
  • 31,035
Ben M
  • 1