
When sudo systemctl start apache2 or restart apache2 fails, Apache almost always tells you why. You just have to read the right log. This guide covers every common variant of the error on Ubuntu and Debian: a configuration syntax error, port 80 or 443 already in use, a missing SSL certificate or module, Unit apache2.service not found, Unit apache2.service is masked, and apache2.service is not active, cannot reload.
Quick answer
sudo apache2ctl configtest # 1. config syntax
sudo ss -tlnp | grep -E ':80 |:443 ' # 2. is the port taken?
sudo journalctl -xeu apache2.service # 3. the real error
sudo tail -n 30 /var/log/apache2/error.log
sudo systemctl start apache2
Step 1: Read the actual error
A message like Job for apache2.service failed because the control process exited with error code is only a summary. Get the details:
systemctl status apache2 --no-pager -l
sudo journalctl -xeu apache2.service --no-pager | tail -40
sudo tail -n 50 /var/log/apache2/error.log
Match the message you see to one of the fixes below.
Step 2: Fix configuration syntax errors
sudo apache2ctl configtest
Anything other than Syntax OK names the file and line number, for example AH00526: Syntax error on line 12 of /etc/apache2/sites-enabled/example.conf. Common causes:
- Typo or unclosed block (
<VirtualHost>,<Directory>) in a site file you just edited. Fix the line, or disable the site withsudo a2dissite example.confto get Apache running again. - Invalid command 'RewriteEngine' or a similar directive: the module isn't enabled. Run
sudo a2enmod rewrite(orssl,headers,proxy_fcgi, whichever the error names). - SSLCertificateFile: file does not exist: the certificate path is wrong, or the certificate was deleted or expired and renewed elsewhere. Correct the path, or reissue the certificate with
sudo certbot --apache. - PHP module conflict (Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe): use
sudo a2dismod mpm_event && sudo a2enmod mpm_prefork, or move to PHP-FPM.
AH00558: Could not reliably determine the server's fully qualified domain name is only a warning. It doesn't stop Apache. Silence it with echo "ServerName localhost" | sudo tee /etc/apache2/conf-available/servername.conf && sudo a2enconf servername.
Step 3: Free port 80 or 443
The error (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80 means another program holds the port:
sudo ss -tlnp | grep -E ':80 |:443 '
- Nginx is the usual culprit. Stop and disable it if you don't need it:
sudo systemctl disable --now nginx. Or move one of them to a different port. - An old Apache process that didn't exit:
sudo pkill -f apache2, then start the service again. - A duplicate
Listen 80inports.confand a site file. Keep it in/etc/apache2/ports.confonly.
Step 4: "Unit apache2.service not found"
systemd has no Apache unit, so Apache isn't installed under that name:
- On Ubuntu or Debian, install it:
sudo apt update && sudo apt install apache2. - On RHEL, Rocky, AlmaLinux, CentOS and Fedora, the service is called httpd:
sudo systemctl start httpd. - If you just installed it, run
sudo systemctl daemon-reloadand try again.
Step 5: "Unit apache2.service is masked"
A masked unit has been deliberately blocked, often by a control panel or by an admin who switched to Nginx. Unmask it:
sudo systemctl unmask apache2
sudo systemctl enable --now apache2
Step 6: "apache2.service is not active, cannot reload"
reload only works on a running service. Start it instead, and fix any error that start reports:
sudo systemctl start apache2
systemctl is-active apache2
This message often appears after a log-rotation or Certbot hook runs while Apache is already down.
Step 7: Check disk space and permissions
df -h /
df -i /
ls -ld /var/log/apache2 /var/run/apache2
A full disk or a deleted log folder stops Apache from writing its PID and log files. Free space, or recreate the folder: sudo mkdir -p /var/log/apache2 && sudo chown root:adm /var/log/apache2.
Step 8: Reinstall Apache as a last resort
sudo cp -a /etc/apache2 ~/apache2-backup
sudo apt install --reinstall apache2 apache2-bin apache2-data
sudo systemctl restart apache2
Only use apt purge apache2 if you're happy to rebuild your configuration from the backup.
Frequently asked questions
How do I fix "Failed to start apache2.service – The Apache HTTP Server"?
Run sudo apache2ctl configtest and sudo journalctl -xeu apache2.service to see the cause. It's usually a config syntax error, a port already used by Nginx, or a missing SSL certificate or module.
Why does it say "Unit apache2.service not found"?
Apache isn't installed, or the system calls it httpd (RHEL-based distributions). Install apache2 with apt on Ubuntu or Debian, or use systemctl start httpd on RHEL-based systems.
How do I unmask apache2.service?
Run sudo systemctl unmask apache2, then sudo systemctl enable --now apache2.
Can Apache and Nginx run on the same server?
Yes, but not on the same port. A common setup is Nginx on ports 80 and 443 as a reverse proxy and Apache on port 8080.


