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

By RunRacks Team · Published

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: apache2 on Ubuntu and Debian, httpd on AlmaLinux and Rocky. The examples use apache2; swap in httpd where needed.

Step 1: Get the real error

Check the service state and the last log lines:

Terminal
sudo systemctl status apache2 --no-pager
sudo journalctl -u apache2 -n 40 --no-pager

Then run Apache's own syntax check:

Terminal
sudo apachectl configtest

A 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:

Text
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 configuration

Read 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.

Fix AH00072: address already in use

This error means another process already listens on port 80 or 443:

Text
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
no listening sockets available, shutting down

Find out what owns the port:

Terminal
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 (or httpd), 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:

Terminal
sudo grep -Rn "^\s*Listen" /etc/apache2 /etc/httpd 2>/dev/null

Each port should appear once.

Fix missing or wrong certificate files

If a certificate was deleted, renamed or never issued, Apache cannot load it:

Text
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 empty

Check which certificates exist:

Terminal
sudo certbot certificates

If the certificate is gone, disable the HTTPS site, start Apache, then issue a new certificate:

Terminal
sudo a2dissite example.com-le-ssl.conf
sudo systemctl start apache2
sudo certbot --apache -d example.com -d www.example.com

A 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:

Text
AH00558: apache2: Could not reliably determine the server's fully qualified domain name

Set a global ServerName to remove it. On Ubuntu and Debian:

Terminal
echo "ServerName localhost" | sudo tee /etc/apache2/conf-available/servername.conf
sudo a2enconf servername

On 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

  1. Run sudo apachectl configtest and confirm Syntax OK.
  2. Start and enable the service:
Terminal
   sudo systemctl enable --now apache2
   sudo systemctl status apache2 --no-pager

The status should read active (running).

  1. Confirm it listens: sudo ss -ltnp | grep apache2 should show ports 80 and, if you use HTTPS, 443.
  2. 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 journalctl for out-of-memory kills or a crashing module. Low-RAM servers may need MPM tuning.
  • `Could not open configuration file`: an Include line 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

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.

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