0 votes
in Wordpress Questions and Knowledgebase by (1.0k points)
retagged by
How to fix "Sorry you are not allowed to access this page" error in Wordpress website?

1 Answer

0 votes
by (1.0k points)

How to fix "Sorry you are not allowed to access this page" error in Wordpress website?

If you encounter with ‘Sorry you are not allowed to access this page’ error with your WordPress site there is nothing to be panicked. Let’s see first what causes this error & then we shall proceed with its fix. When making changes or performing updates to your WordPress site or trying to use it, you may occasionally encounter an error like this.

Basically, this error occurs due to security or permissions issue. However, to find the root cause for the error could be somewhat tricky. For example, there is a chance of having discrepancy in the data that’s being communicated between your website’s files and the database.

If the stored data for a specific theme or a plugin, or component of the WordPress core doesn’t correspond with the version in the database, requests will not be able to process correctly.That would come up with the error as mentioned. Or let’s say, if the username or password in your wp-config.php file doesn’t match up with the database, that can also bring up this error. Finally, another cause is, if your site is using an outdated version of PHP. As such, upgrading your site to latest PHP is highly recommended.

Now let’s see how to fix the error, you may refer below steps and see if it resolves the error:

1. Revert your site to the pre-error state:

If you are confident you know what the last change you made to your site & that caused an error, a simple solution is to revert it. This could be removing the theme or plugin you think to be responsible or using a plugin like WP Rollback to restore an older version. You could also restore your WordPress site from a backup if you have one that was made before the error first occurred.

2. Use WP_Debug to get a list of errors:

To get an idea of exactly what PHP errors might be causing your site’s issue, you’ll need to turn on the WP_DEBUG tool. For that edit your wp-config.php file and add the following line of code :

define( 'WP_DEBUG', true );

This should allow you to see WordPress-generated debug messages on your site’s individual pages. With WP_DEBUG turned on, you can also look at the generated entries located in wp-contents/debug.log.This way, all errors will be displayed in one easy-to-find location.

3. Review your access and error log:

In addition to checking for PHP errors, you’ll also like to check your site's error log. In your hosting account's cpanel you have Error Pages option to track down the errors. This process can help eliminate guesswork and narrow down the potential causes of the error.

4. Retrieve plugin security notifications:

There is a possibility that error you’re experiencing is a direct result of a hack or other any attack. If you have a security plugin installed if any & that sends email alerts when suspicious activity occurs (such as Wordfence plugin Security), then you should check notification mails. That mail may correspond to the time the error first occurred. There are a number of plugins that will enable you to keep a log of all activities that take place on your WordPress site. One best example is WP Security Audit Log. Using this plugin, you can keep track of WordPress core and settings changes, user profile updates, database changes, and much more. As such, it can serve as a useful tool to point the root cause of any “Sorry, you are not allowed to access this page” errors.

5. Check your file permissions:

Another potential reason for this problem is incorrectly allocated file permissions. There are a numerous factors to be considered when ensuring that your file permissions are correct.

Login to cPanel >> Filemanager & navigate to public_html. Within that folder, you’ll need to check files under the subfolders named wp-admin, wp-content, and wp-includes.Get the permissions set to 644 for your files and 755 for the folders & subfolders.

6. Deactivate themes and plugins:

A newly installed or updated theme or plugin can cause the error “Sorry, you are not allowed to access this page”. A wise decision here would be try & deactivate all plugins and your active theme. If you cannot access the WordPress admin dashboard, you’ll need to deactivate your themes and plugins manually via FTP connection. Once you’ve done that, please check to see if the error is still occurring.

 If it is not, you would like to reactivate your theme and individual plugins one by one & then check each time to see if the error is back. When the error returns, you can confirm that the last theme or plugin you reactivated is the main culprit. Simply deactivate it again and remove it from your site.

7. Manually reset your .htaccess file:

If none of this worked then there might be an issue with the code in your .htaccess file. To check this, login to cPanel >> File Manager >> navigate to your public_html folder  and locate your .htaccess file. You’ll need to right-click on it, select Rename, and change the name to .htaccess_old.

Then create a new file with name .htaccess and paste below code & save:

# BEGIN WordPress

RewriteEngine On

RewriteBase /

RewriteRule ^index.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

# END WordPress


The .htaccess file with this should now be reset, and the error will be resolved if the file was at fault.

8. Upgrade your site’s PHP to the latest version:

You can login to cPanel >> Select PHP Version (PHP Selector) & try to select & set latest PHP version.After that check if that has fixed the error.  

9. Check your database prefix :

To check that your site’s database prefix is correct, open up your wp-config.php file, as well as your WordPress database. Then check if the prefix value (i.e. wp_) matches then one available in your database. Once this is corrected in case of any mismatch, you should check to see if the “Sorry, you are not allowed to access this page” issue still occurs on your site. 

10. Export or reset your WordPress site:

Sometimes, WordPress installation issue can also cause error. In that case, you’ll have to export your site to a new WordPress installation in order to fix the error. If not then the last option is to reset your WordPress site completely. Here resetting your database will mean that you lose all content on pages and posts, as well as comments posted by visitors to your site.For that we suggest you to backup everything first and then go for a reset