The Most Popular Extension Builder for Magento 2

With a big catalog of 224+ extensions for your online store

Magento 2 Error: You Don't Have Permission To Access This Server

Your store is running Magento 2 and suddenly got this error You don’t have permission to access Magento on this server. You may get crazy with Linux folder permission in this case. No worries, there is a simple solution for that.

This error indicates that a default document could not be found at the specified URL and that directory listings are not permitted. The permission settings of your server should be changed.

Table of Contents

Magento 2 You Don’t Have Permission To Access/On This Server

You may encounter the problem as follows:


You don't have permission to access /magento on this server.


Option 1

Grant permissions

sudo chown -R $USER:$USER /var/www/magento
sudo chmod -R 755 /var/www

You can replace correct Magento path /var/www/magento

Option 2

In this approach, there are four steps to resolve this issue:

Step 1: Set the Document Root

  • Navigate to the file C:\xampp\apache\conf\extra\httpd-vhosts.conf.

  • Add the following code to the httpd-vhosts.conf file:

 <VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/folder_name/pub"
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost

  • DocumentRoot "C:/xampp/htdocs/folder_name/pub" : installed Magento2 folder path location
  • your desired base URL. (Ex:
  • DocumentRoot "C:/xampp/htdocs/folder_name": Base URl for Magento2.4.1

Step 2: Add Domain in the Hosts File Run Notepad as an administrator.

Run Notepad as an administrator

  • Open the file C:\Windows\System32\drivers\etc\hosts file in your Notepad.

  • Add the following line at the bottom:

  • Restart Apache by clicking on the Stop and Start buttons in XAMPP.

Step 3: Set Domain in Env.php File

  • Open the file app/etc/env.php.
  • Search for downloadable_domains in that file and update the domain URL:
'downloadable_domains' => [

Step 4: Update Base URL in the Database Table

  • Open localhost/phpmyadmin/ in the browser, select the database, and go to SQL Queries.
  • Enter the following command:
UPDATE `core_config_data` SET value='' WHERE path='web/unsecure/base_url';

Step 5: Clear Cache

Run the command:

php bin/magento c:f

That’s how you can fix the error ‘ You don’t have permission to access/on this server’ with ease. If you still have problems, leave comments below!

Happy coding!

Related Post

Image Description
With over a decade of experience crafting innovative tech solutions for ecommerce businesses built on Magento, Jacker is the mastermind behind our secure and well-functioned extensions. With his expertise in building user-friendly interfaces and robust back-end systems, Mageplaza was able to deliver exceptional Magento solutions and services for over 122K+ customers around the world.

Looking for
Customization & Development Services?

8+ years of experiences in e-commerce & Magento has prepared us for any challenges, so that we can lead you to your success.

Get free consultant
development service

    Explore Our Products:

    People also searched for


    Stay in the know

    Get special offers on the latest news from Mageplaza.

    Earn $10 in reward now!

    Earn $10 in reward now!

    go up