Fix XAMPP “Access Forbidden (403)” Error on Localhost (Windows, macOS, Linux)

Fix XAMPP “Access Forbidden (403)” Error on Localhost

Getting a “403 Access Forbidden” error in XAMPP on localhost? Learn how to fix permission and directory access issues on Windows, macOS, and Linux step-by-step.


🧩 Introduction

If you’re trying to access http://localhost or a project in your htdocs folder and see a “403 Access Forbidden” error, you’re not alone. It’s a common issue caused by permissions, Apache configuration, or OS-level restrictions.

This blog explains how to resolve it on Windows, macOS, and Linux/Ubuntu machines.


❗ Common Causes

  • Apache is denying access to directories due to configuration
  • Wrong httpd.conf or httpd-vhosts.conf rules
  • Incorrect folder permissions (especially on macOS/Linux)
  • OS security or antivirus blocking access

🖥️ Fix on Windows

✅ Step-by-Step:

  1. Open httpd.conf File:
    • Go to XAMPP Control Panel > Apache > Config > httpd.conf
  2. Find the Directory Block:
    Look for: <Directory /> AllowOverride none Require all denied </Directory> Change to: <Directory /> AllowOverride all Require all granted </Directory>
  3. Check the htdocs Directory Block:
    Find: <Directory "C:/xampp/htdocs"> Options Indexes FollowSymLinks AllowOverride All Require all denied </Directory> Change Require all denied to: Require all granted
  4. Save the file. Restart Apache.

🍏 Fix on macOS

✅ Step-by-Step:

  1. Open httpd.conf: sudo nano /Applications/XAMPP/xamppfiles/etc/httpd.conf
  2. Update Directory Permissions:
    Find: <Directory "/Applications/XAMPP/xamppfiles/htdocs"> Options Indexes FollowSymLinks AllowOverride All Require all denied </Directory> Change to: <Directory "/Applications/XAMPP/xamppfiles/htdocs"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>
  3. Optional: Enable User Folder Access (if accessing custom folders): <Directory "/Users/yourname/Sites"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>
  4. Restart Apache: sudo /Applications/XAMPP/xamppfiles/xampp restartapache

🐧 Fix on Linux/Ubuntu

✅ Step-by-Step:

  1. Edit Apache Config File: sudo nano /opt/lampp/etc/httpd.conf
  2. Update htdocs Directory Block: <Directory "/opt/lampp/htdocs"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted </Directory>
  3. Check File Permissions:
    Make sure your project folder is readable: sudo chmod -R 755 /opt/lampp/htdocs sudo chown -R $USER:www-data /opt/lampp/htdocs
  4. Restart Apache: sudo /opt/lampp/lampp restart

💡 Bonus Tip: Disable Apache Security Block (if needed)

Sometimes, mod_security or .htaccess rules may block access. Temporarily comment them out if debugging.

Also, ensure your antivirus/firewall isn’t blocking Apache (common in Windows Defender).


📌 Conclusion

The “403 Access Forbidden” error in XAMPP is typically due to default security settings in Apache. By updating directory permissions and Apache configuration, you can regain access to your local projects across any OS.


💬 Still Facing the Issue?

Drop your Apache config block or a screenshot of the error in the comments, and I’ll help you troubleshoot!

Leave a Reply

Your email address will not be published. Required fields are marked *