Solved: forbidden you don’t have permission to access this resource.

Getting a 403 Forbidden error in XAMPP?
If Apache shows “Forbidden – You don’t have permission to access this resource” when you open your localhost website, the problem is usually related to Apache’s configuration, VirtualHost, DocumentRoot, directory access, or permissions.

Quick answer:
A 403 Forbidden error means Apache is running, but it is refusing to serve the requested resource. Check your DocumentRoot, VirtualHost configuration, directory path, Apache access rules, and Magento’s pub directory if you are running Magento 2.

 

In this guide, you’ll learn how to fix the “403 Forbidden – You don’t have permission to access this resource” error or not found the requested url was not found on this server. apache/2.4.58 (win64) openssl/3.1.3 php/8.2.12 server at localhost port 80 error in XAMPP, including common Apache, localhost, VirtualHost, and Magento 2 configuration problems.

What Does the 403 Forbidden Error Mean?

A 403 Forbidden response means that Apache received your request but is refusing to allow access to the requested resource.

You may see an error similar to:

Forbidden

You don't have permission to access this resource.

Apache/2.4.x (Win64)
OpenSSL/...
PHP/...
Server at localhost Port 80
Important:
A 403 Forbidden error is different from an Apache startup error. If Apache itself is shutting down unexpectedly, you need to troubleshoot the Apache startup problem separately.

The exact cause can vary depending on your XAMPP configuration. Common causes include an incorrect DocumentRoot, VirtualHost configuration, inaccessible directory, incorrect Apache access rules, or an incorrect Magento 2 setup.

1. Check the Apache DocumentRoot

One of the most common causes of a 403 error on a local Magento 2 installation is an incorrect Apache DocumentRoot.

If your Magento project is installed inside:

C:\xampp\htdocs\folder_name

your VirtualHost should point Apache to the correct directory.
For Magento 2 installations, the web root is normally the pub directory.

Open httpd-vhosts.conf

Open:

C:\xampp\apache\conf\extra\httpd-vhosts.conf

Add or update your VirtualHost configuration:

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/folder_name/pub"
    ServerName yourname.magento.com

    <Directory "C:/xampp/htdocs/folder_name/pub">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Replace folder_name with the actual folder containing your Magento installation.

Why does the pub directory matter?
Magento 2 is designed to serve the application’s public files from the pub directory rather than exposing the entire Magento installation directory through Apache.

2. Check Your Apache VirtualHost Configuration

If the DocumentRoot is correct but you still receive a 403 error, review your VirtualHost configuration carefully.

Check:

  • DocumentRoot points to an existing directory.
  • The Directory path matches the DocumentRoot.
  • ServerName matches the local domain you are using.
  • The VirtualHost uses the correct Apache port.
  • There are no syntax errors in the configuration.

Example for a Magento 2 Local Domain

<VirtualHost *:80>
    ServerName sonal.magento.com
    DocumentRoot "C:/xampp/htdocs/magento/pub"

    <Directory "C:/xampp/htdocs/magento/pub">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

After changing the configuration, restart Apache from the XAMPP Control Panel.

3. Add Your Local Domain to the Windows Hosts File

If you are accessing Magento through a custom local domain such as:

http://sonal.magento.com

Windows must know that this domain should point to your local computer.

Open Notepad using Run as administrator.
Then open:

C:\Windows\System32\drivers\etc\hosts

Add:

127.0.0.1    sonal.magento.com

Replace sonal.magento.com with your own local domain.

Note:
You only need this step when using a custom local domain. If you are accessing your project directly through localhost, you generally do not need to add a custom domain to the hosts file.

4. Check Apache Directory Access

Apache must be allowed to access the directory specified by your DocumentRoot.
If the directory is not permitted by the Apache configuration, you may receive a 403 Forbidden response.

Check that your VirtualHost includes an appropriate Directory block:

<Directory "C:/xampp/htdocs/folder_name/pub">
    AllowOverride All
    Require all granted
</Directory>

Make sure the path matches your actual Magento pub directory.
A typo or incorrect folder path can cause the configuration to point somewhere other than the directory you intended to serve.

5. Fix 403 Forbidden for Magento 2 on XAMPP

If you are running Magento 2 on Windows using XAMPP, there are several additional settings worth checking.

Set the Magento DocumentRoot to pub

For a typical Magento 2 installation:

C:/xampp/htdocs/folder_name/pub

should be used as the Apache DocumentRoot.

Check the Magento env.php Configuration

If your Magento installation uses a custom local domain, check:

app/etc/env.php

Look for the downloadable_domains configuration if your installation uses it, and make sure the domain matches your local environment.

'downloadable_domains' => [
    'yourname.magento.com'
],
Important:
This setting is Magento-specific. It is not the general cause of an Apache 403 error. Check Apache’s configuration first.

6. Check the Magento Base URL

If you are using a custom local domain, make sure Magento’s configured base URL matches the URL you are using in your browser.

For example:

http://yourname.magento.com/

You can check the Magento base URL in the core_config_data table.

If you need to update it directly from the Magento database, you can use:

UPDATE `core_config_data`
SET `value` = 'http://yourname.magento.com/'
WHERE `path` = 'web/unsecure/base_url';

Replace yourname.magento.com with the domain configured for your local environment.

Before running a database UPDATE:
Make sure you have selected the correct Magento database and have a backup if the database contains important development data.

7. Clear Magento Cache

After changing Magento configuration, clear the Magento cache.
From your Magento project directory, run:

php bin/magento cache:flush

Then restart Apache and reload your website.

8. What If You See “404 Not Found” Instead?

A 404 error is different from a 403 Forbidden error.

ErrorWhat it generally meansWhat to check
403 ForbiddenApache found the request but access is not permitted.DocumentRoot, Directory rules, VirtualHost and access configuration.
404 Not FoundThe requested resource or route could not be found.URL, DocumentRoot, Magento routing and file paths.
Apache shutdown unexpectedlyApache is failing to start or remain running.Ports, configuration errors, dependencies and Apache logs.

9. Still Getting the 403 Forbidden Error?

If the previous steps did not solve the problem, don’t keep changing configuration randomly.
Instead, identify exactly where the request is being rejected.

Work through this checklist:

  1. Confirm Apache is running in XAMPP.
  2. Confirm the DocumentRoot points to the correct directory.
  3. Confirm the Magento pub directory exists.
  4. Check the VirtualHost configuration.
  5. Check the Directory access rules.
  6. Check the Windows hosts file if using a custom local domain.
  7. Check the Magento base URL.
  8. Check the Apache error log for additional information.
  9. Restart Apache after making configuration changes.
Don’t just change the Apache port.
A port change will not fix a 403 Forbidden response if Apache is already running and the real problem is the VirtualHost, DocumentRoot, directory access, or Magento configuration.

Still Stuck With Your XAMPP or Magento Error?

If you’ve tried the steps above and you’re still getting a 403 Forbidden error, Apache configuration problem, localhost error, or Magento issue, you can ask for help.

Leave a comment below with the exact error message and tell me what you have already tried. I’ll do my best to help you identify the problem.

For direct troubleshooting help, you can also contact me on WhatsApp – Chat with Sonal on WhatsApp →

Frequently Asked Questions

Why am I getting 403 Forbidden in XAMPP?

A 403 Forbidden error can occur when Apache is running but does not have permission to serve the requested resource. Common areas to check include the DocumentRoot, VirtualHost, Directory access rules and local project configuration.

How do I fix “You don’t have permission to access this resource” in XAMPP?

Start by checking your Apache DocumentRoot and VirtualHost configuration. Make sure the directory exists and Apache is allowed to access it using an appropriate Directory configuration.

Why does Magento 2 show 403 Forbidden on localhost?

For a Magento 2 installation on XAMPP, check that Apache’s DocumentRoot points to the Magento pub directory and that the corresponding Directory configuration allows Apache to access it.

What should the Magento 2 DocumentRoot be?

For a typical Magento 2 installation, Apache should serve the Magento application’s pub directory.

C:/xampp/htdocs/folder_name/pub

Do I need to edit the Windows hosts file?

Only if you are using a custom local domain such as yourname.magento.com. If you are accessing the project directly through localhost, you generally do not need a custom hosts entry.

Will changing Apache from port 80 to 8080 fix a 403 error?

Usually, no. A 403 Forbidden response means Apache is responding but refusing access to the requested resource. Changing the port is generally relevant to a port conflict, not a directory access or VirtualHost problem.

What if Apache is showing “shutdown unexpectedly” instead?

That is a different problem. Apache must first be running successfully before you troubleshoot a 403 response. If Apache is shutting down unexpectedly, check the Apache error message, ports, configuration files and dependencies.

Can I get help fixing my XAMPP or Magento error?

Yes. Leave a comment below with the exact error message and what you have already tried. You can also message me  for direct troubleshooting help.

I hope this guide helped you fix the 403 Forbidden error in XAMPP.

If this guide helped you, feel free to leave a comment below and let me know. I’d love to hear that it worked for you!

If you’re still stuck, don’t keep guessing—leave a comment with the exact Apache error, your XAMPP/Apache version, and what you have already tried. I’ll do my best to help you identify the cause.