Fixed: ‘Sorry, You Are Not Allowed To Access This Page’ Error

Oct 22, 2020

Fixed: ‘Sorry, You Are Not Allowed To Access This Page’ Error

Oct 22, 2020

Stuck trying to access a page on your WordPress site?

You may have admin access but something is preventing you from viewing or making changes to a particular page. 

Finding out what that something is can be frustrating. And while you spend time resolving the error, other tasks are put on hold. 

Your visitors are affected and your revenue will take a hit. 

The biggest problem is that there are so many possible solutions, you’d probably get tired before you resolve the error. 

We’ve analysed over 240,000 WordPress sites and we’ve seen our clients face this error. So we’ve created this guide to help you solve the error ‘sorry, you are not allowed to access this page’ and get you to the solution in the fastest time possible. 

What is ‘Sorry, you are not allowed to access this page’ error?

This is a fairly common error that you can encounter on your WordPress site:

Although this looks like an error message, it’s meant to be a security feature that prevents unauthorized users from accessing areas of your site when they don’t have the necessary permissions.

Therefore, the error occurs due to an issue with security or permissions on your site. There could be a misconfiguration or discrepancy in the data in your WordPress files and/or your WordPress database. 

What causes the error ‘Sorry, you are not allowed to access this page’?

As we mentioned before, this error is difficult to fix because it has such a long list of possible solutions. We want to help you find the right solution, without trying a whole bunch of things. To do this, we need to understand the cause of the error. 

1. Incorrect File Permissions 

The most likely reason you’re seeing the error is that there’s a permission setting that’s blocking your access. Basically, WordPress doesn’t recognize you as an authorized user or an administrator. You’ll need to check your file permissions.

2. Corrupt WordPress Files

There could be incorrect information or configurations in your WordPress core installation. If you haven’t updated WordPress in a while, updating it will resolve the issue. Similarly, if you recently updated it, you might need to rollback the update and see if that fixes the error. If the error persists, you’ll need to reinstall WordPress.

3. Corrupt Plugins or Themes

There could be incorrect information or configurations in one of your WordPress plugins or themes. Certain plugins modify your database tables. If it accidentally deleted something in your database, this error can pop up. We’ll show you how to find the culprit plugin or theme.

4. Incorrect Data in the wp-config File

If your database username and password don’t match, this error will show up. You’ll need to check your wp-config file to resolve this.

5. Outdated PHP Version

PHP is a programming language that powers most of the things you see on your website – both on the front end and the back end. 

Just like WordPress receives updates, PHP also gets updates on a regular basis. If your website is running on an outdated version of PHP, it can cause errors like this.

We’ll show you how to check your PHP version and update it.

These are the five most likely causes of the error on your site. If you’ve figured out what’s causing it, you can skip ahead to the solution from the list below.

Fastest Solutions To Get Access To WordPress Page

Often, the simplest solutions work best. So before you troubleshoot, we recommend giving these 3 steps a shot:

1. Clear your cache & refresh the page 

Sometimes, your site may be displaying old and redundant content that is stored in your browser or server. Delete your browser cookies and cache. You can do this under the Settings tab in your browser. Under Clear History or Clear Browsing Data, make sure you select Cache and Cookies.

In case you’re using a caching plugin on your WordPress site, we suggest you clear your cache using the plugin as well.

To refresh your page, use the F5 key on your keyboard to refresh your browser’s page or hit the Refresh button.

2. Try a different browser 

Your browser has its own settings and permissions. Sometimes, these settings may override your site’s settings. Conflicts can also arise if you have different tabs open on your browser. We suggest accessing the same page from a different browser like Google Chrome, Mozilla Firefox, Safari, Opera, or Qwant.

3. Restore your backup 

If you have a backup copy of your website, you should try restoring your backup before attempting other measures. It will help bring your site back to normal quickly. 

However, this will only work, if you have a recent backup where you will lose little to no data. 

If these easy steps haven’t done the trick, let’s begin troubleshooting the error.

Things To Do Before You Troubleshoot 

Detecting and fixing errors on your site requires some manual modification. There is a certain amount of risk involved as a slight misstep can cause further damage to your site. So we recommend taking two important steps before beginning:

1. Take a Backup of Your Site

Take a fresh backup of your website before you make any changes to your site. You can get a backup in under a few minutes.

Install our BlogVault plugin on your site. Select the plugin, enter your admin email address, and it will take an automated backup. 

2. Create a Staging Site

Next, we don’t recommend troubleshooting on your live site. Your live site needs to be up and running for your visitors and customers. 

Instead, you can set up a staging site which is an exact copy of your website. Here, you can diagnose the cause and find the right solution, without worrying about breaking your website. 

Any changes you make here won’t affect your live site. 

You can create a staging site using your web host or any WordPress staging plugin. If you used BlogVault to take a backup of your site, you can set up a staging site in one click. 

blogvault visit staging site

BlogVault will set up a staging site that is password-protected to keep it private and hidden from search engines and visitors. 

When you visit the staging site, you’ll need to enter the username and password. And to access wp-admin of this staging site, just add the words ‘wp-admin’ to the URL, like so:

Staging site URL

The wp-admin credentials are the same as your live site. 

Also, once you are done fixing the error on staging, you only have to merge it to your live website. There is no need to repeat the process.

Now, you can begin to safely troubleshoot the error, ‘Sorry, you are not allowed to access this page.’

Fix ‘Sorry, you are not allowed to access this page’ Error

Since there are many steps involved, to make it easier to follow, we’ve divided them into two sections:

1. Detecting the root cause of the error ‘Sorry, you are not allowed to access this page’ 

Before you try multiple steps, there are two ways in which you can pinpoint the cause of the error. This will help narrow down the solution faster. 

A. Enable Debugging Mode

There’s a nifty feature in WordPress called Debug mode that will display what error is occurring on your site. This is usually used by developers and we don’t ordinarily recommend enabling it. If you’re a first-time user, make sure you’re doing this on a staging site. 

There are WordPress debugging plugins that will automatically activate or deactivate debugging mode for you. You can also enable it manually by adding a line of code to your wp-config file:

  • Go cPanel in your web hosting account. Access File Manager, and open a folder called public_html. You’ll see a file called wp-config.php. Right-click and Edit this file. Find this line:

define( ‘WP DEBUG’, false )

  • Change ‘false’ to ‘true’. If the line doesn’t exist in your wp-config file, add it to the top of the file. 
  • Save and exit the file. 

Now, visit your wp-admin dashboard. You’ll see an error message that will indicate where the problem lies, like so:

stdClass::$plugin in /www/WordPress/public_html/wp-contents/plugins/talk/class-wp.php on line 152.

From this, you can determine that the problem lies on line 152 in the code of a plugin called Talk.

B. Check Activity Log

You may have enabled an audit or activity log on your WordPress site. You can refer to the log to see what changes were made recently. This will help narrow down the possible causes.

If you’ve been able to pinpoint the possible cause, you can jump ahead to the right solution to resolve the error immediately. If you still haven’t been able to determine what exactly is creating the problem, don’t worry. We’ve got you covered. We’ve listed the measures you can take in order of the most likely solutions to the least likely ones. You can work your way down the list.

2. Resolving the error ‘Sorry, you are not allowed to access this page’ 

Here is a list of measures you can take to fix the error on your site and regain rightful access to your page.

1. Issues with WordPress 

a. Check file permissions 

b. Update WordPress 

c. Rollback a recent update 

d. Reinstall WordPress 

2. Issues with Plugins and Themes

a. Disable plugins 

b. Switch to default theme 

c. Update plugins and themes or rollback any recent updates

3. Issues with WordPress Files or Database

a. Check wp-config file 

b. Check .htaccess file

c. Check wp_options table 

4. Issues with PHP

a. Upgrade PHP version

1) Issues with WordPress 

When core WordPress files are corrupted or the permission settings are incorrect, you’ll see errors like ‘Sorry, you are not allowed to access this page.’

We recommend first checking your file permissions and then moving on to other measures. 

a) Check WordPress File Permissions 

Your WordPress website is made up of a number of files and folders, and every file and folder has a set of permissions. This limits public access to your files and grants permissions to view, edit, and/or execute these files only to authorized users.

There are three permission settings:

  1. Read – View the data and contents of a file or folder
  1. Write – Modify, add, or delete files
  1. Execute – Run and execute files and perform functions and commands.

If these permissions are incorrectly configured, then you may lose access to a certain page or post. Sometimes, you can lose access to your entire website as well.

To make sure your WordPress file permissions are correct, follow these steps:

Step 1: Log into your web hosting account. Go to cPanel > File Manager, and open public_html. 

Step 2: There are tons of files inside and manually checking file permissions of each just isn’t feasible. We recommend browsing through the public_html folder and viewing file permissions collectively first. 

The last column in cPanel shows a 3-digit number which indicates the file permissions:

Each number denotes a specific permission setting. If you’re curious to know what each number means, you can learn more about permission settings in our in-depth guide to WordPress File Permissions.

WordPress recommends the following file permissions:

  • Files – 644 or 640
  • Directories – 755 or 750

If you see any file or folder that has a number that’s different from this recommendation, you can fix it easily. Select the file or folder, and then click on Permissions.

Permissions in cpanel

A box will open up with the permission settings, like so:

WP file permission

Enter the correct permission settings. Make sure you stick to the recommended file permissions which are 644 or 640 for WordPress files, and 755 or 750 for directories or folders.

Click on Change Permissions. Now visit the page in question and see if you have regained access.

b) Update WordPress 

WordPress is constantly being developed and enhanced, and new versions are released quite often. Running your site on outdated WordPress installations can eventually cause conflicts and incompatibility issues on your site. 

If you see updates available on your site, run the update:

Update Now on dashboard

We emphasize again to first test the update on a staging site. If you haven’t updated your website in a while, the update has the potential to cause issues. Learn more about how to safely update your WordPress site.

However, if the update resolves the problem, you can update your live site.

c) Rollback a Recent Update 

Updates don’t always go smoothly. Sometimes, a conflict between the WordPress core and a plugin can break your site or cause errors like the one you’re experiencing.

If you recently updated your WordPress site, you can try rolling back the update:

You can use WP Downgrade to quickly undo an update to your WordPress installation. If you need more detailed guidance, follow our guide on rolling back the core update.

d) Reinstall WordPress 

There are times when WordPress files get corrupted. Errors can be introduced through plugins or by another user. This is a likely cause, especially if you’ve been running your website for many years. 

Now, reinstalling WordPress is a big step. It’s risky but if you do this on a staging site, then you don’t have to worry about it going wrong. The process needs in-depth explanation and we have a handy guide to reinstalling WordPress that you can follow.

2. Issues with Plugins and Themes

Similar to the WordPress core, plugins and themes can also cause incompatibility issues on your site. Let’s look at the measures you can take to determine if a plugin or theme is causing the issue.

a) Disable Plugins 

On your wp-admin dashboard, access Plugins. Select all the plugins, and then Deactivate them. 

Now, check your WordPress website in incognito mode and check the page you are trying to access. If the error has disappeared, you can be sure the cause is a plugin.

To pinpoint the culprit, reactivate your plugins one by one. Check your website each time to see if the error reoccurs. When you find the plugin causing the issue, you may need to update it to fix the issue. If you don’t require the plugin, we suggest deactivating and deleting the plugin from your dashboard. 

PRO TIP: You can also install Plugin Detective on your WordPress site. It helps you find culprit plugins faster by troubleshooting the error. 

b) Switch to default theme 

You can also check to see if your theme is the root cause behind the error on your site. On your WordPress dashboard, access your themes under Appearance. Activate a default WordPress theme like Twenty Twenty, and your theme will automatically be deactivated.

Activate default theme

Now, visit your site in incognito mode again. If the error has disappeared, you’ve found the root cause!

If your theme is the issue, it is difficult to just delete it. Contact the theme’s developer and report the issue. They will release a new version with a bug fix. 

If you have multiple themes installed on your site, we recommend deleting them and only keeping the one you need. Even if you don’t use these inactive themes, they can cause incompatibility and security problems.

c) Update plugins and themes or rollback any recent update

To check if a plugin or theme update is causing the error, you can rollback the update:

To easily undo an update to a theme or plugin, use the WP Rollback plugin.

If the error disappears, the error likely lies with that particular plugin or theme update. You’ll need to wait for the developers to fix the issue, or you can report the bug to them.

Learn more about rolling back a plugin/theme update.

3) Issues with WordPress Files or Database

Your WordPress site is made up of two components: Files and a Database. The files contain all your site’s configurations and settings, as well as your media. The database contains your site’s content as well as a few configurations as well. 

Any incorrect information in these two components can cause WordPress to revoke your access. 

Here’s what you need to do:

a) Check wp-config file

Your wp-config file contains your database details. If the details don’t match, WordPress will give you this error: ‘Sorry, you are not allowed to access this page.’ 

To make sure the database details are correct, you need to check your wp-config file. You can access this in your hosting account > cPanel > File Manager > public_html. 

Locate the wp-config file, right-click and Edit the file.

PRO TIP: If you don’t have access to cPanel, you can use an FTP client like FileZilla to access this file. You’ll need your FTP credentials for this method.

Inside this file, look for your database details:

Now, go to cPanel > phpMyAdmin. Make sure your database details match:

If you recently migrated your site or moved from a localhost to a server, check your database prefix. Make sure the prefix ‘wp_’ matches the prefix of the tables. 

PRO TIP: If you have multiple databases listed and you’re not sure which is yours, open the database, and open a table like wp_posts. If you recognize the posts, then you can be sure it’s your database.

b) Check .htaccess file

Next, check your .htaccess file. 

Caution: The .htaccess file is a sensitive file and is very critical to the functioning of your website. Always use a staging site to test any changes first. We recommend downloading a copy of the .htaccess file before you make any changes. 

To access the .htaccess file, log into your web hosting account. Go to cPanel > File Manager, and open a folder called public_html. 

Inside the public_html folder, you can also find the .htaccess file. In case you don’t see it, go to Settings and select Show Hidden Files. This will reveal the .htaccess file.

Show hidden files .htaccess

Next, select and delete the .htaccess file.

If the error disappears once you delete the .htaccess file, you can simply generate a fresh .htaccess file. On your wp-admin dashboard, go to Settings > Permalinks and simply click on Save Changes. This will automatically create a new .htaccess file for you. 

c) Check wp_options table 

Certain plugins have caused this error by deleting the wp_user_role row in the wp_options table in the WordPress database. 

You can fix this by copying the wp_user_roles code from a fresh WordPress installation. 

Go to cPanel > phpMyAdmin. Select your database and open the wp_options table. Check if the following row is present: wp_user_roles

If it’s been deleted, you can add it by clicking on Insert. A new window opens. 

Under option_name, enter wp_user_roles. Under option_value, you’ll need to insert a code snippet that you can get from a fresh WordPress installation.

Refer to this helpful post on the WordPress support forum.

PRO TIP: Remember to replace ‘wp_’ with your own database prefix.

4. Issues with PHP

If you’re using an outdated version of PHP on your website, you should see this warning message on your wp-admin dashboard:

Even if you don’t see this message, you can check the PHP version in cPanel > phpMyAdmin. 

If the PHP version is outdated, you can update it easily. We have a detailed guide on this: How to Update the PHP Version on WordPress. 

By now, we’re confident you’ve resolved this error on your site and have regained access to your page.

Bonus Tips: What To Do If You Can’t Fix The Error

If the stubborn error is still present on your site, here’s a few suggestions that you may find helpful:

1. Ask for help on the WordPress Support Forum – WordPress users are ever ready to help each other out on the WordPress Support Forum. You can post the specific details of the issue you’re facing and someone will help you out. 

There are also other popular forums like Quora, Reddit, and StackOverflow. You can browse through the solutions provided for the error or post a fresh question

2. Contact your web host – If your web host has set certain permissions, it could be conflicting with your site’s permissions. Connect with customer support to check if it’s an issue on their end. 

What Next?

Whether you’ve been running WordPress for a long time or you’re new to it, there’s always an error that can catch you off guard. In addition, errors can reoccur on your site. So it’s best to be prepared with a plan of action:

  1. Always have a backup of your website ready. When things go wrong, you can restore your backup quickly to make sure your workflow and your visitors aren’t affected.
  1. Use a staging site to experiment and troubleshoot. This will ensure that your live site is never affected or damaged during the process. 
  1. Bookmark this article and keep it handy so that you have a checklist of measures to take to resolve the error fast. 

If one of the steps we’ve mentioned above helped you resolve the error, give us a shoutout on Twitter. We’d love to hear from you.

Try BlogVault’s Backup & Staging Plugin

0 Comments

Share via
Copy link
Powered by Social Snap