How to Fix Common Apache Errors (500/403/AH Errors)

A reference guide to the most common Apache errors and their direct fixes, including Apache's distinctive "AH" (Apache HTTP) error codes.

500 Internal Server Error

Usually caused by a broken .htaccess file, a PHP fatal error, or incorrect file permissions.

sudo tail -f /var/log/apache2/error.log

Test if the issue is .htaccess by temporarily renaming it:

mv .htaccess .htaccess.bak

403 Forbidden

sudo chown -R www-data:www-data /var/www/yoursite
sudo chmod -R 755 /var/www/yoursite

Also verify the <Directory> block includes:

Require all granted

AH00558: Could Not Reliably Determine the Server's Fully Qualified Domain Name

Harmless startup warning — set a global ServerName to silence it:

sudo nano /etc/apache2/apache2.conf
ServerName localhost

AH00013: Pre-configuration Failed / Syntax Error

Always validate before restarting:

sudo apache2ctl configtest

This reports the exact file and line number of the syntax error.

AH00526: Invalid Command (Module Not Loaded)

A directive from a module that isn't enabled. Enable it:

sudo a2enmod MODULE_NAME
sudo systemctl restart apache2

Port 80 Already in Use

sudo ss -tulpn | grep :80

Usually another web server (Nginx) is already bound to the port.

.htaccess Rules Not Working

Confirm AllowOverride All is set in the site's <Directory> block and that mod_rewrite is enabled:

sudo a2enmod rewrite
sudo systemctl restart apache2

PHP Files Download Instead of Executing

sudo apt install libapache2-mod-php -y
sudo a2enmod php8.3
sudo systemctl restart apache2

Adjust the PHP version to match what's installed.

Diagnostic Checklist

  1. sudo apache2ctl configtest — validate config syntax first
  2. sudo systemctl status apache2 — confirm the service is actually running
  3. sudo tail -f /var/log/apache2/error.log — the fastest path to the real cause
  4. Check file/directory ownership and permissions for 403/500 errors

Related Articles

  • How to Install Apache on Ubuntu & Debian
  • Apache Virtual Hosts: Hosting Multiple Websites
  • How to Install Let's Encrypt SSL with Certbot (Nginx & Apache)
  • apache errors, 500 internal server error, 403 forbidden, ah00558, apache troubleshooting
  • 0 Kasutajad peavad seda kasulikuks
Kas see vastus oli kasulik?

Seotud artiklid

How to Install Nginx on Ubuntu & Debian (Complete Guide)

Nginx is one of the world's most widely used web servers, known for its speed, low resource...

How to Install Apache on Ubuntu & Debian (Complete Guide)

Apache HTTP Server is one of the most widely used web servers, valued for its stability, flexible...

Nginx Virtual Hosts (Server Blocks): Hosting Multiple Websites on One VPS

Nginx "server blocks" (the equivalent of Apache's virtual hosts) let you host multiple...

Apache Virtual Hosts: Hosting Multiple Websites on One VPS

Apache Virtual Hosts allow a single server to host multiple independent websites, each identified...

How to Configure Nginx as a Reverse Proxy for Node.js/Docker Apps

A reverse proxy sits in front of your application, handling incoming traffic on standard ports...