When you’re the admin of your site and you get the message “Sorry, you are not allowed to access this page” and you start thinking “I am allowed to access this page. I’m the admin!”. It can also undo your hard work in addition to preventing you from making significant changes on your site.
But don’t worry! We’ll give you a variety of tried and tested methods to fix this error in this article.
Note: You should always have a backup of your website data.
What are the Causes of “Sorry, You Are Not Allowed to Access This Page” Error
When you make or try to use changes to your WordPress site, you may occasionally encounter an error:
This error is essentially due to a security or permission problem. However, Determining the root cause is where things can become difficult. For example, the data communicated between the files of your website and the database may differ.
If the data stored for a theme, plugin or component of the WordPress core does not match the version in the database, requests cannot be processed correctly, and the error “Sorry, you can not access this page” occurs.
If your wp-config.php username or password does not match the database, this error can also be triggered. Finally, if your site uses an outdated version of PHP, another potential cause is. Therefore, it is highly recommended to upgrade to the current version of PHP (we will cover this later).
We’ll take you through some troubleshooting methods to solve the WordPress error throughout the rest of this article. We will start with the most basic methods that will most likely fix the problem before moving on to more advanced solutions that can work if the cause is not simple.
Use WP_DEBUG to Get a List of Errors
You will need to turn on the WP DEBUG tool to see what PHP errors could cause your site’s problems. Open the wp-config.php file and add the following code line (if it is not already present):
define( ‘WP_DEBUG’, true );
Once you have done that, you can see debug messages generated by WordPress on the individual pages of your site. By reading this, you can identify the cause of the error “Sorry, you are not allowed to access this page”.
You can also look at the generated entries in wp-contents/debug.log when WP DEBUG is turned on. All errors will be displayed in one location that is easy to find.
Review the Error Log
You will also want to check the error log of your server in addition to checking for PHP errors in your files. This process can help to eliminate guesswork and reduce the possible causes of the error. The process to check your error log naturally varies depending on your hosting provider.
However, if you can not detect a probable cause of this error via WP DEBUG or the error log of your host, you can learn more by using a security plugin.
Check Your File Permissions
Another possible cause of this problem is incorrect file permissions. When ensuring that your file permissions are correct, there are a variety of factors to consider. Below, two easy ways to fix file permission errors are discussed.
You can solve this task via FTP. Open your File Transfer Protocol (FTP) and enter the details of your host in the relevant fields. Navigate to public/HTML. In this folder, the subfolders named wp-admin, wp-content, and wp-includes must be highlighted. Next, select permissions for files:
In the Change file attributes window that appears, you must ensure that the numerical value is 755, the Recurse to the subdirectory box is checked, and Apply only to directories:
To apply any changes, select OK. Return to public/HTML and select each file in it. Check to exclude the three directories that you have already changed. You will have to right- click on the files and again select File permissions:
The file permissions error should be resolved by this process (if there is one). It also ensures that basic permissions are properly configured for your WordPress files. In summary, the directory permissions should be 0755, whereas the file permissions should be 0644.
Manually Reset Your .htaccess File
If none of the solutions have worked so far, the code in your .htaccess file may have a problem. Navigate to your public_html folder using FTP and find your file.htaccess. You have to right- click, select Rename, and change the name to .htaccess backup.
Right-click on the file again, and download it this time.
Open the file in the text editor you prefer (e.g. TextEdit or Notepad). Change the name to .htaccess and replace the text of the file with the following snippet:
Save the file and upload it back to your website afterwards. The .htaccess file should now be reset, and if this file was the problem, the error will be resolved.
Check Your Database Prefix
What if you updated the PHP version of your website, but you still see the “Sorry, you are not allowed to access this page” error. If you developed your WordPress site using a local environment and migrated it to a live server recently, there may be a discrepancy between the database table prefix.
You will need to open your wp-config.php file and your WordPress database again to verify that the database prefix of your site is correct. You will then have to check if the value of the prefix (i.e. wp_) matches one in your database. Once every discrepancy has been detected and corrected, you should check whether the problem “Sorry, you are not allowed to access this page” still occurs on your website.
As a WordPress user, it is important to understand the possible reasons for common errors and to know what to try.