Skip to content
Home » News » Magento Permission Denied Error

Magento Permission Denied Error

An image of  "the bash: bin/magento: Permission denied" error

The Permission Denied error in Magento 2 is a common issue. It happens when the bin/magento file doesn’t have the right permissions to run. Thus, it occurs due to insufficient file permissions, incorrect ownership settings, or missing role privileges. 

For example, you attempt to run a Magento CLI command like:

bin/magento ...  

And see an error message such as:

bash: bin/magento: Permission denied  

Why Does the Magento Permission Denied Error Occur?

This error usually happens because:

  1. No Permission to Execute: The system doesn’t see a certain file as executable.
  2. Access Issues: The user under which the command is being run doesn’t own the file or lacks the right permissions.
  3. Restricted Directory Settings: The folder containing bin/magento has limited access.

How to Fix It

Here’s what you can do to resolve the problem:

1. Add Execute Permissions

The easiest fix is to give the file execute permissions. Open your terminal, go to the folder with bin/magento, and run:

chmod +x bin/magento  

This command allows the file to run properly.

2. Use PHP to Run the Command

If the Permission Denied error in Magento 2 still occurs, try running the command with php before it, like this:

php bin/magento ...  

This ensures the system runs the command correctly.

3. Adjust Folder Permissions

If the issue continues, it might be due to the folder’s permissions. You can change them by running:

chmod -R 755 /path/to/magento  

This temporarily grants access to everyone. Be sure to restrict permissions again after finishing your tasks.

Conclusion

The Magento Permission Denied error is simple to fix. You just need to adjust the file or folder permissions, or use php to run the command. If you are still having issues, contact support for help.

Author

Leave a Reply

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