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

How can you fix the “Sorry, you are not allowed to access this page” error without having access to your WordPress dashboard? Though this error doesn’t leave any severe damage on your site, it can frustrate you as you’re not able to make changes or undo anything you’ve created before.

In this tutorial, we highlight 9 sure-fire ways to fix the WordPress “Sorry, you are not allowed to access this page” error.

Before proceeding with the comprehensive guide, it’s vital to properly understand the error determine what causes it to occur.

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

“Sorry, you are not allowed to access this page” is quite a common error to WordPress users. It happens when there are some misconfigurations or authorization issues occur. As a result, you can’t save some customizations on the site. Though it’s not a severe error, addressing the root causes can take much time.

wordpress sorry you are not allowed to access this page error

For instance, a mismatch between username or password in your wp-config.php file with the database can prompt this error. In addition, if the data transferred between the files and the website database is not consistent, the error also shows up.

In other words, once data stored in plugins, themes, or in other WordPress files doesn’t match with the one in the database, WordPress won’t be able to execute any action requests. At that point, an error warning of “Sorry, you are not allowed to access this page” appears. You might lose access to your page until it’s resolved.

Another possible cause goes to your PHP. If your site is using an outdated version of PHP, chances are the root cause comes from here, and you must update your PHP right away.

Last but not least, access limits from file permission settings can be the next reason. If WordPress fails to recognize you as an authorized user or administrator, it will block your access, which triggers the error.

So, to sum up, the possible root causes of this problem come from

  • Mismatched data in the wp-config.php file
  • Incorrect file permissions
  • An outdated version of PHP
  • Corrupt plugins and themes

Since you’ve figured out what causes the “Sorry, you are not allowed to access this page” error, let’s jump to the main part of solving this problem.

#1. Check Your WordPress Error Log

First, you need to check your WordPress server’s error log to pinpoint the cause. Some hosting providers allow you to access the error log via a dashboard, which you just log in to and view the log.

In case no dashboard is provided, you use credentials in your hosting control panel and get access to your site via an FTP client or file manager app. Click on /wp-content/ folder and search for a debug.log file.

If it includes the recent activities that you’ve made before the error prompts, that’s great! You can go about fixing it. Otherwise, you’ll need to try the following solutions.

debug,log

#2. Go through Your File Permissions

As we stated above, file permissions decide who can access which files and folders in WordPress. In this case, this can be likely that WordPress refuses to recognize your authorization to view certain page areas, though you’re listed as an admin.

To check your file permissions, again, you access your server using SFTP. Once you’re logged in, click on the public_html directory, select wp-admin, wp-content, and wp-includes at once. Next, right-click on these folders and hit “File Permissions.”

check file permissions

A file permissions dialog box shows up. Do the following:

  • Fill “755” in the Numeric Value field (755 is for all folders and sub-folders.)
  • Check the “Recurse into subdirectories” option
  • Select Apply to directories only
    change folder sub folder attributes

Click “OK” and your SFTP will start setting your folders and subfolders.

Next, you need to select all files in public_html, right-click on them, and select File permissions again.

public html file permission

This will also trigger a settings box. Similarly,

  • Set the Numeric Value to 644
  • Select the “Recurse into subdirectories” checkbox
  • Check Apply to files only
    change file attributes

(Image source)

Hit OK and you’re done. Now you should go back to your WordPress site and check if the “Sorry, you are not allowed to access this page” is gone. If not, then move on to the next method.

#3. Detect Changes in wp-config.php File

Since the wp-config.php file defines all of the configuration settings for your WordPress site, you need to make sure that the file has not been changed or compromised.

Again, use SFTP to access your wp-config.php file and look for suspicious or strange changes or tweaks. This process is much easier if you install file integrity monitoring.

#4. Disable All Plugins

If you suspect a plugin addition or upgrade causes the “Sorry, you are not allowed to access this page”, we recommend you to deactivate all of your plugins then reactivate them one by one. After you turn off all plugins and the error goes away, the root cause comes from one of your plugins.

Since you’re locked out of your dashboard, you have to disable plugins via FTP. The process is a little bit tricky, but don’t worry, our detailed instructions will guide you through it.

  1. Connect to your website using an FTP client. Once successfully accessed, go to the /wp-content/ folder and look for a sub-directory named “plugins.”
  2. Right-click on the folder, choose “Rename”, and enter a different name.
    rename plugin folders

Now, all your plugins have been deactivated. Get back to your WordPress site and check if the error is resolved.

#5. Activate a Default Theme

In case the plugin deactivation doesn’t work, then you can check if there is anything wrong with your theme. Have you recently updated your theme? If yes, it’s advisable to switch it to WordPress default themes like Twenty Twenty or Twenty Nineteen to resolve the problem.

Similarly, you also activate a default theme via SFTP. Once accessing your server, navigate to the /wp-content/ folder > themes.
wp content themes

Now, you need to rename the folder with your active theme then go back to your site and log in. You should see a notification informing you that a default theme has been reactivated, while the current theme gets broken.

If the error disappears, then you should rename the themes folder, and look through each individual theme to seek the faulty one.

Bear in mind that deactivating a theme can cause bad damage to your site performance and workflow. You may need to reach out to developers for consultancy and a fix.

#6. Generate a New .htaccess File

Another way to troubleshoot the “Sorry, you are not allowed to access this page” issue is by creating a new .htaccess file. Connect back to your site with SFTP and head to your public_html folder to search for your .htaccess file.

Once you’ve found it, right-click and rename your existing .htaccess file, for example, .htaccess-backup. Next, right-click it and select Download. Next, open the file in a text editor and insert the following code snippet into it:

#BEGIN WordPress

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCOnd %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

#END WordPress

Now rename the file back to .htaccess, save your changes, and upload it to your server. If this file causes the “Sorry, you are not allowed to access this page” error, then it should now be fixed.

#7. Ensure Consistent User Role and Table Prefix

Technically, the database contains almost everything on your WordPress site, and user roles are no exception. If the user role prefix in the database is different from an administrator role, you lose access to certain parts of your site.

To check for discrepancies, you need to visit your wp-config.php file.

  1. Use SFTP and phpMyAdmin to access your database.
  2. Go to the wp-config.php file and look for the $table_prefix. Note down its value.
    phpmyadmin
  3. Select the wp_users table, find your username and ID, and note them down.
  4. Head over to the wp_usermeta table and check the wp_capabilities row. Your user role is in the meta_value field.
    wp-cababilities

(Image credit to wpkube.com)

If the row displays any words different from the administrator, click Edit and change the wording. Keep in mind that you stay away from any of the surrounding text.

Finally, return to your WordPress and check whether the error has gone.

#8. Reset Your WordPress Site

In the worst scenario, the error comes from an installation issue. To deal with it, you may need to reset your WordPress site. Before getting your hands on, you have to back up your WordPress site to prevent it from losing any important data and content.

Some reset WordPress plugins, such as WP Reset or Advanced WordPress Reset can help you with the reset task. You can also contact your WordPress host for any further help.

Note: we only recommend this method for new WordPress sites, which haven’t had much data.

#9. Update Your PHP

As we mentioned before, an outdated PHP is one of the primary causes of the “Sorry, You Are Not Allowed to Access This Page” error. Apart from that, running an old version of PHP can expose your site to security risks, including getting hacked. As such, not only updating the PHP version does bring back your site to normal but it also tightens your site security.

Before starting the upgrade process, backing up your site is a must. Plus, you need to make sure your site is compatible with the latest version of PHP. It’s advisable to test it on your WordPress staging site.

Once done, you can run the update. There are 2 options for you to choose from. If you’re using VPS, you can upgrade your PHP using the command line. Either way, in case you don’t have access, you should change the PHP version in the control panel.

If you’re with another provider, you may be able to follow a similar process via your own control panel. After logging in to your control panel, in your cPanel dashboard, go to the Software section > Select PHP Version.
select php version

Next, click on the current PHP version. A dropdown shows up containing all PHP versions available on your hosting server. Select a recent version then Set as Current to save the changes.
update-php-version

(Image credit to fixrunner.com)

It’s recommended that you contact your web host for further support.

Bring Your WordPress Site Back to Normal!

In this tutorial, we’ve spelled out some possible causes of the WordPress “Sorry, you are not allowed to access this page” error. They can be mismatched data in the wp-config.php file, incorrect file permissions, outdated version of PHP, and corrupt plugins and themes.

We’ve also put forward 9 ways to troubleshoot this issue. You need to check the WordPress error log to address the causes, detect changes in the wp-config.php file, and check your file permissions.

If these methods don’t make an impact, try disabling all plugins and themes, updating your PHP to the latest version, and resetting the .htaccess file or even the whole WordPress site.

Remember to always back up your site to save all of your crucial data.

Have any questions on this topic? Raise it up in the comment section below! In the meantime, check out our blog for more insightful articles about WordPress, WooCommerce tips in general, and password-protecting WordPress in particular.