WordPress Tutorial

10 Ways to Fix the “Sorry, You Are Not Allowed to Access This Page” Error in WordPress

How to fix Sorry you are not allowed to access this page error in WordPress

While working on your WordPress site, there are few things more frustrating than encountering the “Sorry, you are not allowed to access this page” error. In addition to preventing you from making important changes on your site, it can also undo your hard work.

But don’t panic! In this article, we’ll provide you with a variety of tried-and-tested methods for fixing this error. We’ll cover how to:

  1. Revert your site to the pre-error state.
  2. Use WP_Debug to get a list of errors.
  3. Review your access and error log.
  4. Retrieve plugin security notifications.
  5. Check your file permissions.
  6. Deactivate themes and plugins.
  7. Manually reset your .htaccess file.
  8. Upgrade your site’s PHP to the latest version.
  9. Check your database prefix.
  10. Export or reset your WordPress site.

By the end of this article, you’ll be well prepared to tackle this issue whenever it occurs. Let’s dive in!

What Causes the “Sorry, You Are Not Allowed to Access This Page” Error

When making changes to your WordPress site or trying to use it, you may occasionally encounter an error that looks like this:

Sorry, you are not allowed to access this page error in WordPress

Fundamentally, this error occurs as a result of a security or permissions issue. However, determining the root cause is where things can get tricky.

For instance, there could be a discrepancy in the data that’s being communicated between your website’s files and the database. If the stored data for a theme, plugin, or component of the WordPress core doesn’t correspond with the version in the database, requests will not be able to process correctly, and the “Sorry, you are not allowed to access this page” error will occur.

If the username or password in your wp-config.php file doesn’t match up with the database, that can also trigger this error. Finally, another potential cause is if your site is using an outdated version of PHP. As such, upgrading to the current version of PHP is highly recommended (we’ll cover this later on).

Throughout the rest of this article, we’ll take you through some troubleshooting methods for resolving the WordPress error. We’ll begin with the most basic methods that are most likely to fix the issue, before moving on to more advanced solutions that may work if the cause isn’t straightforward.

10 Ways to Fix the “Sorry, You Are Not Allowed to Access This Page” Error in WordPress

Before trying any of these methods, it’s highly recommended that you back up your WordPress site. This will ensure that you can easily restore your site if you make a mistake while troubleshooting this issue. With that in mind, let’s begin!

1. Revert Your Site to the Pre-Error State

As is the case with any issue you’re troubleshooting, it helps to recall the last change you made on the site. After all, that change might have caused the error. It could have been anything from updating to a new version of WordPress, to migrating your site from a local environment, to making major PHP changes. You’ll also want to consider the last plugin or theme you installed (or updated).

If you are confident you know what the last change you made to your site was, a simple solution is to revert it. This could mean removing the theme or plugin you believe 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.

On Hostinger, all web hosting plans include automatic backups. Thus, you may easily grab a backup of your website files or MySQL databases using Files › Backups section of the control panel.

Website and MySQL Database Backups on Hostinger

In the event that you aren’t sure what change you made might have caused the “Sorry, you are not allowed to access this page” error, you may benefit from having access to a list of probable causes. This brings us to the next method.

2. Use WP_DEBUG to Get a List of Errors

To get a readout of what PHP errors might be causing your site’s problems, you’ll need to turn on the WP_DEBUG tool. To do this, open up your wp-config.php file and add the following line of code (if it is not already present):

define( 'WP_DEBUG', true );

Once you’ve done that, you will be able to see WordPress-generated debug messages on your site’s individual pages. By reading through these, you may be able to pinpoint the cause of the “Sorry, you are not allowed to access this page” error.

With WP_DEBUG turned on, you can also look at the generated entries located in wp-contents/debug.log. That way, all errors will be displayed in one easy-to-find location.

3. Review Your Error Log

In addition to checking for PHP errors within your files, you’ll also want to check your server’s error log. This process can help eliminate guesswork and narrow down the potential causes of the error.

Naturally, the process for reviewing your error log will vary according to your hosting provider. If you have a plan here at Hostinger, you can read through our guide to checking your site’s error log. We cover how to use your .htaccess file to log errors and discuss some of the more common error types that could potentially lead to the “Sorry, you are not allowed to access this page” message.

If you can’t detect a likely cause of this error via WP_DEBUG or your host’s error log, however, you may be able to learn more by using a security plugin.

4. Retrieve Plugin Security Notifications

It’s always possible that the error you’re experiencing is a direct result of a hack or other attack. If you have a security plugin installed that sends email alerts when suspicious activity occurs (such as Wordfence Security), you should check your inboxes and your spam folder. You may find a notification there that corresponds to the time the error first occurred.

If you don’t already have a solution for this, there are a number of excellent plugins that will enable you to keep a log of all activities that take place on your WordPress site. One notable example is WP Security Audit Log:

WP Audit Security Log Screenshot

Using this plugin, you can keep track of WordPress core and settings changes, user profile updates, database alterations, and much more. As such, it can serve as a useful tool for pinpointing the root cause of any “Sorry, you are not allowed to access this page” errors.

5. Check Your File Permissions

Another potential cause of this problem is incorrectly configured file permissions. There are a variety of factors to consider when ensuring that your file permissions are correct. Below, we discuss two easy ways to resolve file permission errors.

If you have a web hosting plan on Hostinger, there is an awesome tool that will do the job for you. It is located in the control panel’s Other › Fix File Ownership section. With a single mouse click, the tool will locate and fix any files or directories with permission issues.

Fixing file and directory permissions on Hostinger

Alternatively, the same task can be performed via FTP. Open up your File Transfer Protocol (FTP) client, and enter your host’s details into the relevant fields. Then, navigate to public_html. Within that folder, you’ll need to highlight the subfolders named wp-admin, wp-content, and wp-includes. Next, select File Permissions:

FileZilla FTP Root Folder Screenshot

In the Change file attributes window that appears, you’ll need to ensure that the numerical value is 755, the Recurse into subdirectories box is checked, and Apply to directories only is selected:

Change file attributes window of FileZilla screenshot

Select OK to apply any changes. After that, return to public_html and select every file within it. Make sure to exclude the three directories which you already altered. You’ll need to right-click on the files, and select File permissions once more:

FileZilla Change File Permissions for public_html screenshot

In the next Change file attributes window, check to make sure that the numerical value is 644, the Recurse into subdirectories box is checked, and Apply to files only is selected. Then, hit OK:

FileZilla change file attribute window set to apply to files only screenshot

This process should resolve the file permissions error (if there is one). Plus, it ensures that the basic permissions for your WordPress files are configured correctly. To sum up, the directory permissions should be 0755, while file permissions should be set to 0644.

6. Deactivate All Themes and Plugins

As we mentioned earlier, a newly-installed or updated theme or plugin can cause the “Sorry, you are not allowed to access this page” error to occur. As such, a sound strategy is to deactivate all plugins and your active theme. In the event that you cannot access the admin dashboard, you’ll need to deactivate your themes and plugins manually via FTP.

Once you’ve done that, check to see if the error is still occurring. If it is not, you’ll want to reactivate your theme and individual plugins one by one, checking each time to see if the error is back. When the error returns, you can be almost positive that the last theme or plugin you reactivated is the culprit. Then, simply deactivate it again and remove it from your site.

If this process does not work, however, keep your FTP client open. You’ll need to use it for the next fix as well.

7. Manually Reset Your .htaccess File

If none of the solutions so far have worked, there might be an issue with the code in your .htaccess file. To deal with this, navigate to your public_html folder using FTP, and locate your .htaccess file. You’ll need to right-click on it, select Rename, and change the name to .htaccess_backup.

Then right-click on the file again, and download it this time:

Filezilla .htaccess file download

Open up the file in your preferred text editor (such as TextEdit or Notepad). Change the name back to .htaccess, and replace all the text in the file with the following snippet:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

After that, save the file and upload it back to your site. The .htaccess file should now be reset, and the error will be resolved if this file was the problem.

8. Upgrade Your Site’s PHP to the Latest Version

A common issue that can cause the “Sorry, you are not allowed to access this page” error is an outdated version of PHP. In addition, using an old version of PHP can pose security risks to your WordPress site. For that reason, it’s worth updating whether or not this fixes the error.

Before upgrading to the latest version of PHP, it’s important to ensure that your site will be compatible with it.  Once you have done this, you’ll also need to make sure your WordPress site is backed up (if you haven’t already done that).

It’s also advisable to create a local staging copy of your site before upgrading. This will enable you to test how your site will function with the latest version of PHP.

Once you’ve tested out your site, and are happy with how it runs using the latest version of PHP, there are two methods for upgrading permanently. If you have a Virtual Private Server (VPS), you will likely be able to upgrade directly via the command line. However, if you don’t have this level of access, you’ll need to change it via the control panel or contact your hosting provider for assistance.

If you’re using Hostinger, the control panel provides you all the necessary tools to manage your PHP version and extensions with ease. All you have to do is navigate to Advanced › PHP Configuration section.

9. Check Your Database Prefix

What if you’ve updated your site’s version of PHP, but you’re still seeing the “Sorry, you are not allowed to access this page” error? If you developed your WordPress site using a local environment, and have recently migrated it to a live server, there could be a database table prefix discrepancy at fault.

To check that your site’s database prefix is correct, you’ll again need to open up your wp-config.php file, as well as your WordPress database. You’ll then need to check if the prefix value (i.e. wp_) matches then one available in your database. Once every discrepancy has been detected and corrected, 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

If every other fix you’ve tried has proven unsuccessful, there are two other methods you should consider. We’ve said this before, but it’s particularly important to ensure that your WordPress site is backed up before trying either of these solutions.

Sometimes, a WordPress installation issue can cause the “Sorry, you are not allowed to access this page” error. In that case, you’ll need to export your site to a new WordPress installation in order to resolve the error. There are a few ways to approach this task and you may find an in-depth guide on how to do it here.

The last resort option is to reset your WordPress site completely. It should be noted that resetting your database will mean that you lose all content on pages and posts, as well as comments posted by visitors. If this content is backed up and easily accessible, however, you’ll be able to restore it after the reset.

Conclusion

As a WordPress user, it’s crucial to understand the potential causes of common errors and know what solutions to try. Armed with the troubleshooting methods we’ve covered in this article, the “Sorry, you are not allowed to access this page” error should no longer be a cause for concern.

Do you have any questions or extra solutions for resolving this particular WordPress error? Let us know in the comments section below!

About the author

Will Morris

Will Morris is a staff writer at WordCandy. When he's not writing about WordPress, he likes to gig his stand-up comedy routine on the local circuit.

Add Comment

Click here to post a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Have a website?

Join thousands of webmasters who get our free newsletter with tips on how to drive more traffic and revenue to their websites!

Please wait...

Thank you for sign up!

More in WordPress Tutorial
XAMPP WordPress
How to Use XAMPP to Set Up a Local WordPress Site (In 3 Steps)

Close