HTTPError.net

The fastest way to diagnose, understand, and fix any HTTP status code

Apache

How to Fix 403 Forbidden Error in Apache

Quick Fix

The most common cause of 403 errors in Apache is: Incorrect file/directory permissions

Quick solution: Directories should be 755: sudo find /var/www/html -type d -exec chmod 755 {} \;

The 403 Forbidden error in Apache indicates a problem specific to your Apache configuration or environment. This guide provides platform-specific solutions.

Common Causes in Apache

Step-by-Step Solutions

Solution 1: Check File Permissions
  1. Directories should be 755: sudo find /var/www/html -type d -exec chmod 755 {} \;
  2. Files should be 644: sudo find /var/www/html -type f -exec chmod 644 {} \;
  3. Ensure correct ownership: sudo chown -R www-data:www-data /var/www/html
  4. Test the site
Solution 2: Check Apache Configuration
  1. Edit Apache config: sudo nano /etc/apache2/sites-available/000-default.conf
  2. Ensure Directory directive allows access:
  3. \n Options Indexes FollowSymLinks\n AllowOverride All\n Require all granted\n
  4. Test config: sudo apache2ctl configtest
  5. Restart Apache: sudo systemctl restart apache2
Solution 3: Add Index File
  1. Create index file: echo '' > /var/www/html/index.php
  2. Or create HTML: echo '

    It works!

    ' > /var/www/html/index.html
  3. Ensure DirectoryIndex is set in Apache config: DirectoryIndex index.php index.html
Solution 4: Check .htaccess
  1. Temporarily rename .htaccess: mv .htaccess .htaccess.old
  2. Test if site works
  3. If fixed, review .htaccess for Deny directives
  4. Check for: Order deny,allow / Deny from all
  5. Update or remove problematic rules
Solution 5: Disable SELinux (Temporarily)
  1. Check SELinux status: getenforce
  2. If Enforcing, temporarily disable: sudo setenforce 0
  3. Test if site works
  4. If fixed, set correct SELinux contexts: sudo chcon -R -t httpd_sys_content_t /var/www/html
  5. Re-enable SELinux: sudo setenforce 1

Prevention Tips