Apache is the web server behind a large share of the internet, and when it breaks, your site goes down with it. This article walks through the most frequent Apache errors you’ll see in logs or the browser, explains what causes each one, and gives you the exact steps to fix them on your own server.
The 5 Most Common Apache Errors
These are the errors that appear most often in Apache error logs and on user screens. Each one has a distinct signature and a distinct fix.
- 403 Forbidden – You don’t have permission to access the resource.
- 404 Not Found – The URL doesn’t map to any existing file or handler.
- 500 Internal Server Error – A generic failure, often from a bad .htaccess or a PHP crash.
- 502 Bad Gateway – Apache can’t get a valid response from a backend (like PHP-FPM or a proxy).
- 503 Service Unavailable – The server is overloaded, down, or refusing connections.
Less common but still frequent: 408 Request Timeout, 409 Conflict, and 413 Request Entity Too Large.
Why Apache Errors Happen: The Basics
Apache is a process-based web server. It listens on a port (usually 80 for HTTP, 443 for HTTPS), accepts connections, and serves files or runs scripts. Every error you see is Apache telling you that something in that chain failed.
The error log (/var/log/apache2/error.log on Debian/Ubuntu, /var/log/httpd/error_log on RHEL/CentOS) is your first stop. It records the exact time, the error level, and a message that usually explains what went wrong. The access log (access.log) shows the requests, but the error log is where the real diagnosis happens.
Many errors are configuration mistakes: a missing DirectoryIndex, a typo in httpd.conf, or an .htaccess file with a directive Apache doesn’t understand. Others are resource issues: the server ran out of file descriptors, memory, or worker threads.
403 Forbidden: Permissions and Config
A 403 means Apache understood the request but refuses to serve it. The most common cause is file permissions. The Apache user (often www-data or apache) needs read permission on the file and execute permission on every directory in the path.
- Check permissions:
ls -l /var/www/html/index.html– the file should be readable by the Apache user (e.g.,644). - Check directory permissions:
ls -ld /var/www/html– directories need755(or at least711). - If using
.htaccess, verify theAllowOverridedirective in the main config isn’t set toNonefor that directory. - Look for a
Deny from allorRequire all denieddirective in a<Directory>block or.htaccess. - Check SELinux on RHEL-based systems:
restorecon -Rv /var/www/htmlor usechconto set the correct context.
A 403 can also appear if the Indexes option is off and there’s no index.html in a directory – Apache refuses to list the files.
500 Internal Server Error: .htaccess and PHP
A 500 is a catch-all. Apache can’t tell you the exact problem because it’s often a misbehaving script or a syntax error in a config file. The error log will have the real message.
- Check the error log:
tail -f /var/log/apache2/error.log– look for “syntax error� or “Premature end of script headers�. - If you recently changed
.htaccess, comment out lines one by one to isolate the culprit. A common mistake is using an Apache 2.4 directive (likeRequire) on an Apache 2.2 server (which usesOrder/Allow). - For PHP sites, check the PHP error log (often
/var/log/php_errors.logor configured inphp.ini). A fatal error in a script will trigger a 500. - Run
apachectl configtest(orhttpd -t) to validate the main config files before restarting. - If you use
mod_rewrite, a bad rule can cause an infinite loop that results in a 500. Check the rewrite log if enabled.
502 Bad Gateway and 503 Service Unavailable
These two are closely related. A 502 means Apache, acting as a reverse proxy, received an invalid response from the backend. A 503 means the backend is completely unavailable or Apache is refusing connections because it’s overloaded.
Common backends: PHP-FPM, Node.js, Gunicorn, or another web server behind Apache. The fix usually involves checking whether the backend process is running and listening on the expected port or socket.
- Check the backend service:
systemctl status php7.4-fpm(or whatever you run). - Verify the socket or port in the Apache proxy config. For PHP-FPM, look for
SetHandler proxy:unix:/run/php/php7.4-fpm.sock– if the socket path is wrong, you get a 502. - For a 503, check Apache’s
MaxRequestWorkersandServerLimit– if you exhaust all worker threads, new connections get a 503. - Check system resources:
free -mandtopto see if memory or CPU is maxed out. - If the backend is a separate server, check network connectivity and firewall rules.
404 Not Found and Redirect Loops
A 404 is straightforward: the file doesn’t exist at the path Apache resolved. But it can be tricky when you have mod_rewrite rules that are supposed to route everything to a front controller (like in Laravel or WordPress).
- Check the file exists:
ls -l /var/www/html/contact.php– if it’s missing, that’s the problem. - If you use pretty URLs, make sure
AllowOverride Allis set andmod_rewriteis enabled (a2enmod rewrite). - Look for a redirect loop – you’ll see “redirect� in the error log. This often happens when an HTTP to HTTPS redirect is misconfigured, or when a
RewriteRulematches itself. - Check the
DocumentRoot– if it points to the wrong directory, everything will 404.
How to Diagnose Any Apache Error
When you see an error, don’t guess. Follow this systematic process:
- Check the error log first – it’s the single most reliable source of truth.
- Run
apachectl configtestto catch syntax errors before restarting. - Check file and directory permissions for the affected path.
- If the error is intermittent, look at resource usage (memory, file descriptors, connection limits).
- If you recently made changes, revert them one by one.
Also, remember that Apache 2.4 changed many access control directives. If you’re migrating from 2.2, Order Allow,Deny must be replaced with Require all granted – mixing them causes 500s and 403s.
Frequently Asked Questions
How do I find the Apache error log?
On Debian/Ubuntu, it’s /var/log/apache2/error.log. On RHEL/CentOS, it’s /var/log/httpd/error_log. You can also check the ErrorLog directive in your config file – it might be set to a custom path.
Why do I get a 403 when permissions are correct?
Check SELinux (on RHEL) or AppArmor (on Ubuntu) – they can block access even with standard permissions. Also, verify that the Apache user actually has execute permission on every parent directory, not just the final one.
How do I fix a 500 error from .htaccess?
Rename .htaccess to something like .htaccess.bak and reload the page. If the error goes away, the file is the problem. Add back lines one at a time until you find the culprit.
What does “Request exceeded the limit of 10 internal redirects� mean?
This is a rewrite loop. Your RewriteRule is matching a URL that it rewrites to itself, or a chain of rules keeps triggering each other. Add a condition like RewriteCond %{REQUEST_URI} !^/index.php$ to break the loop.
Can I fix Apache errors without restarting the server?
Yes, for config file changes you can run apachectl graceful – it tells Apache to reload configs without dropping connections. For .htaccess changes, no restart is needed at all; Apache reads them on every request.
Why do I get a 503 when my site gets traffic spikes?
Your MaxRequestWorkers is too low. Each connection uses a worker thread, and when they’re all busy, Apache queues requests and eventually returns 503. Increase MaxRequestWorkers (and ServerLimit if needed), but watch your RAM – each worker uses memory.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Ecommerce Product Photography Tips for Setup
- Jio 5G Upgrade Data Plan: What You Get
- Surface Pro OLED vs LCD: Which Display Is Better?
- Enable Floating Keyboard in Gboard: Step-by-Step
- Best Open World Driving Games to Play While Waiting for GTA
- Can Your TV Play 3D Movies? Compatibility & Setup