Apache will not start — port in use, ServerName, or a bad module
Apache is explicit about why it stopped. The startup output and the error log name the file and line.
What you see
systemctl start apache2 fails, or reports success while nothing is listening. AH00558 is a warning that is frequently mistaken for the cause.
What is actually wrong
Another process on port 80 or 443, a syntax error in a site file, a module enabled without its dependency, or a certificate path that does not exist.
Codes and articles
Fixes (2)
Find what already holds the port
Address already in use.
Find the process.
sudo ss -tlnp | grep -E ':80 |:443 'sudo fuser -v 80/tcp 443/tcp
It is usually nginx installed alongside Apache, or an old Apache process that did not exit.
systemctl is-active nginx apache2 httpd 2>/dev/nullps aux | grep -E 'apache|httpd|nginx' | grep -v grep
Both web servers installed and both enabled is extremely common after following two different guides. Whichever starts first wins the port and the other fails at every boot.
Decide which one should own the port and disable the other.
sudo systemctl disable --now nginxsudo systemctl enable --now apache2
If both are wanted, put one behind the other on a different port rather than fighting over 80.
sudo sed -i 's/^Listen 80$/Listen 8080/' /etc/apache2/ports.confsudo systemctl restart apache2
sudo ss -tlnp | grep -E ':80 |:8080 'curl -sI http://localhost/ | head -3
Read the configuration test output
A syntax error, a module problem, or the ServerName warning.
Test the configuration. It names the file and the line.
sudo apachectl configtestsudo apache2ctl -S
AH00558 about the fully qualified domain name is only a warning and never prevents startup. Silence it by setting ServerName, but do not spend time on it if the server is failing for another reason.
echo 'ServerName localhost' | sudo tee /etc/apache2/conf-available/servername.confsudo a2enconf servernamesudo systemctl reload apache2
This warning appears at every start on a default install and is the thing most people latch on to. It is noise; the real error is elsewhere in the output.
For a module error, enable the dependency as well as the module.
sudo a2enmod ssl headers rewrite proxy proxy_httpsudo systemctl restart apache2
Check certificate paths actually exist if SSL is involved.
sudo apache2ctl -S 2>&1 | grep -i sslsudo grep -rn 'SSLCertificate' /etc/apache2/sites-enabled/ | while read -r l; do echo "$l"; done
Read the error log for anything the test does not catch.
sudo journalctl -u apache2 -n 40 --no-pagersudo tail -40 /var/log/apache2/error.log
sudo apachectl configtest && systemctl is-active apache2Where this stops. This write-up was written and checked by hand. It says what each step changes, how to confirm it worked and how to reverse it, and anything destructive is flagged before you reach it. If it does not match what your machine is doing, search the Support Centre for the exact code or message — and when something needs a person, get in touch.