Fix Apache failed to start (AH00072 port in use and config errors)
When Apache will not start, run a config test, read journalctl, and fix the usual causes - AH00072 port already in use, syntax errors, missing certificates and the AH00558 ServerName warning.
- Beginner
- Linux VPS
- 5 min read
If systemctl start apache2 or systemctl start httpd fails, every site on the server goes down. The good news is that Apache always says why. This guide shows how to get the exact message, then fixes the causes you will meet most often: a configuration error, another program on port 80 or 443, and a certificate file that no longer exists.
Before you start
- A Linux VPS with Apache 2.4 on Ubuntu, Debian, AlmaLinux or Rocky Linux.
- SSH access with
sudo. - The service name:
apache2on Ubuntu and Debian,httpdon AlmaLinux and Rocky. The examples useapache2; swap inhttpdwhere needed.
Step 1: Get the real error
Check the service state and the last log lines:
sudo systemctl status apache2 --no-pager
sudo journalctl -u apache2 -n 40 --no-pagerThen run Apache's own syntax check:
sudo apachectl configtestA healthy config prints Syntax OK. Anything else names the file and line that is wrong.
Fix configuration syntax errors
A typical failure looks like this:
AH00526: Syntax error on line 12 of /etc/apache2/sites-enabled/example.com.conf:
Invalid command 'ProxyPass', perhaps misspelled or defined by a module not included in the server configurationRead it in three parts: the file, the line, and the reason.
- `Invalid command`: the module for that directive is not loaded. On Ubuntu and Debian, enable it, for example
sudo a2enmod proxy proxy_http. On AlmaLinux and Rocky, install the package or check/etc/httpd/conf.modules.d/. - `<VirtualHost> was not closed`: a closing tag is missing or misspelled.
- `DocumentRoot must be a directory`: the path does not exist. Create it, or fix the typo.
After each fix, run sudo apachectl configtest again until it says Syntax OK.
If you just enabled a new site and Apache fails, disable it to get the other sites back online while you fix it: sudo a2dissite example.com.conf && sudo systemctl start apache2.
Fix AH00072: address already in use
This error means another process already listens on port 80 or 443:
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
no listening sockets available, shutting downFind out what owns the port:
sudo ss -ltnp | grep -E ':(80|443)\s'The last column shows the program. Common culprits:
- Nginx: both web servers want the same ports. Stop and disable the one you do not use:
sudo systemctl disable --now nginx. - A second Apache process left over: run
sudo pkill -f apache2(orhttpd), then start the service again. - A Docker container or app publishing port 80. Stop it or move it to another port.
The same error also appears when Listen 80 is written twice, for example in ports.conf and again in a site file. Search for duplicates:
sudo grep -Rn "^\s*Listen" /etc/apache2 /etc/httpd 2>/dev/nullEach port should appear once.
Fix missing or wrong certificate files
If a certificate was deleted, renamed or never issued, Apache cannot load it:
AH00526: Syntax error on line 30 of /etc/apache2/sites-enabled/example.com-le-ssl.conf:
SSLCertificateFile: file '/etc/letsencrypt/live/example.com/fullchain.pem' does not exist or is emptyCheck which certificates exist:
sudo certbot certificatesIf the certificate is gone, disable the HTTPS site, start Apache, then issue a new certificate:
sudo a2dissite example.com-le-ssl.conf
sudo systemctl start apache2
sudo certbot --apache -d example.com -d www.example.comA key and certificate that do not match produce AH02565 or key values mismatch. Point SSLCertificateKeyFile at the key that belongs to the certificate.
Silence the AH00558 ServerName warning
This message is a warning, not the reason Apache failed:
AH00558: apache2: Could not reliably determine the server's fully qualified domain nameSet a global ServerName to remove it. On Ubuntu and Debian:
echo "ServerName localhost" | sudo tee /etc/apache2/conf-available/servername.conf
sudo a2enconf servernameOn AlmaLinux and Rocky, add ServerName localhost near the top of /etc/httpd/conf/httpd.conf. If the service still fails after this, look for a different error further up the output.
Check it works
- Run
sudo apachectl configtestand confirmSyntax OK. - Start and enable the service:
sudo systemctl enable --now apache2
sudo systemctl status apache2 --no-pagerThe status should read active (running).
- Confirm it listens:
sudo ss -ltnp | grep apache2should show ports 80 and, if you use HTTPS, 443. - Load your site in a browser.
Troubleshooting
- `Permission denied: AH00072 make_sock: could not bind to address`: on AlmaLinux and Rocky, SELinux blocks a non-standard port. Allow it with
sudo semanage port -a -t http_port_t -p tcp 8080. - Apache starts, then stops a few seconds later: check
journalctlfor out-of-memory kills or a crashing module. Low-RAM servers may need MPM tuning. - `Could not open configuration file`: an
Includeline points to a deleted file. Remove the line or restore the file. - Starts by hand but not after reboot: the service is not enabled. Run
sudo systemctl enable apache2.
Next steps
- Stop memory-related crashes: Tune Apache MPM settings.
- Re-issue HTTPS correctly: Secure Apache with Let's Encrypt.
- Read the logs in more depth: Find and read Apache access and error logs.
- Still stuck on your RunRacks server? Open a ticket.
Was this guide helpful?
Still stuck?
Ask RunRacks AI for a quick answer, or open a ticket and our team will take a look at your server.
Related guides
Troubleshooting
Fix Nginx 413 Request Entity Too Large
Nginx returns 413 Request Entity Too Large when an upload is bigger than client_max_body_size. Raise the limit for one site or the whole server, match PHP's limits, and test.
- Beginner
- Linux VPS
- 5 min read
Troubleshooting
Is your ISP or router blocking port 12230? How to tell
Work out whether your internet provider, home router, parental controls or a proxy is blocking RDP port 12230, and collect the details support needs to help.
- Intermediate
- Windows VPS · Admin RDP
- 5 min read
Troubleshooting
Fix "Your credentials did not work" in Remote Desktop
Fix rejected RDP logins: username format, the right password, stale saved credentials, account lockout and Remote Desktop permissions.
- Beginner
- Windows VPS · Admin RDP
- 3 min read