Cookies setting

Cookies help us enhance your experience on our site by storing information about your preferences and interactions. You can customize your cookie settings by choosing which cookies to allow. Please note that disabling certain cookies might impact the functionality and features of our services, such as personalized content and suggestions. Cookie Policy

Cookie Policy
Essential cookies

These cookies are strictly necessary for the site to work and may not be disabled.

Information
Always enabled
Advertising cookies

Advertising cookies deliver ads relevant to your interests, limit ad frequency, and measure ad effectiveness.

Information
Analytics cookies

Analytics cookies collect information and report website usage statistics without personally identifying individual visitors to Google.

Information
mageplaza.com

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

Vinh Jacker | 04-20-2016

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:

Forbidden

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

Solution

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"
    ServerName yourname.magento.com
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
</VirtualHost> 

  • DocumentRoot "C:/xampp/htdocs/folder_name/pub" : installed Magento2 folder path location
  • yourname.magento.com: your desired base URL. (Ex: mageplaza.magento.com)
  • 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:

127.0.0.1 yourname.magento.com

  • 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' => [
    'yourname.magento.com'
],

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='http://yourname.magento.com/' 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

x
    Jacker

    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.



    Related Post

    Website Support
    & Maintenance Services

    Make sure your store is not only in good shape but also thriving with a professional team yet at an affordable price.

    Get Started
    mageplaza services