Fix “Not Allowed to Access this Page” Error in WordPress

Picture this: You’re working away on your WordPress site and then bam! You see this puzzling and face contorting error:

Sorry, you are not allowed to access this page.

“How is this even a thing?” you quietly shout. “I am allowed to access this page. I’m the admin!”

The frustration continues when you realize the fix isn’t so cut and dry since there are multiple and equally possible reasons for the error.

Not to worry. Today, I’ll share more detail on the cause of this error as well as how to troubleshoot and fix for both single installs of WordPress and Multisite networks.

Please note: If you’re not able to resolve this error after going through the details below, you can ask our expert support team for help – for free!

The Course of wp-admin Never Did Run Smooth

At its core, this error is a permissions or security issue, but there could be many reasons why it appears in the first place.

In cases where you are the admin, there’s a discrepancy with the data that’s communicated between your WordPress site’s files and the database. The WordPress core, a plugin or theme has a certain set of stored data that doesn’t match what’s recorded in the database. Since the data doesn’t match, the request can’t be processed.

This can happen in cases where the database details such as the username and password in the wp-config.php file don’t match what’s set up in the database.

It could also be that you have a version of PHP installed on your server that isn’t compatible with WordPress, which could also pose a security risk.

These are only a couple examples, but it serves to illustrate that the possible reasons for this error are widespread and can’t always be immediately identified.

With that in mind, here’s how to troubleshoot the “Sorry, you are not allowed to access this page” error that can appear on WordPress sites.

An example of the error in Safari.
The error states you aren’t allowed to access the page, but you’re the admin.

Double, Double Toil and Troubleshooting

Assuming you’re logged in as the admin or super admin and not an extra account with a different user role, here’s how to troubleshoot the issue. You don’t necessarily have to follow it from top to bottom, but it is recommended.

The list starts with basic troubleshooting steps and fixes and progresses to more advanced options.

Before you begin troubleshooting, it’s recommended that you create a backup of your site. If the issues get worse, you can restore your site to the start of your troubleshooting and try again.

Revert Your Changes

Try to remember the last thing you did before the error appeared as it’s the likeliest culprit.

For example, if you updated a plugin or theme. It can also happen when you migrate your site from a local environment to a live server. Updating the WordPress core to version 4.6 or 4.6.1 has also been known to cause this error.

If you’re able to identify the cause, try to revert your changes. You can do this manually by removing the cause such as the problem plugin or theme. You can also restore your site from a backup you have saved to resolve the error immediately, as long as the backup was created before the error first emerged.

You can refer to the posts above for details.

Turn on WP_DEBUG

The boolean WP_DEBUG can list the errors on the front end that are currently plaguing your WordPress site. With this particular error, this usually doesn’t turn up any results. Regardless, it’s a good idea to give it a go since it could inform you of errors possibly relating to the plugins or themes you have installed that are contributing to the problem.

Try turning on WP_DEBUG and check the error log once that’s done. Also, be sure to add the logging option to WP_DEBUG so any resulting errors are printed to a private log. This prevents errors being posted to the front end, which is a security risk.

For details, check out Debugging WordPress: How to Use WP_DEBUG.

Check Your Error and Access Logs

After checking your log file that’s created when you turn on the debugging mode, it’s also a good idea to check the error and access logs that are on your server.

If you see errors listed, it may help narrow down the issue. You can also use your access log to help determine what the last action was before the error appeared.

You can also check to see if there was any unauthorized access to your site. If a hacker was able to access your files or database, they could have locked you out by changing vital data that would limit your account access to the pages you can’t access, while granting themselves access to it.

Security Plugin Notifications

It’s possible a hacker was able to infiltrate your site and in such a case, it’s likely it was at least recorded if you have a security plugin installed.

If you receive email notifications from the security plugin you may have installed, check to see if you have received any in your email inbox and don’t forget to check the spam folder in case your email provider has strict spam rules in place.

File Permissions

This error could be the result of a permissions problem so it’s important to check that your file permissions have been set correctly.

For details, check out Understanding File Permissions and Using Them to Secure Your Site.

Deactivate Plugins and Themes

One of the likeliest causes is a plugin or theme you have installed, especially if the error appeared after you installed, activated or updated one before the error occurred.

You can deactivate your installed plugins and themes manually through FTPsince you can’t access the admin dashboard. Be sure to leave the default theme active.

For details, check out Disable a WordPress Plugin Without Access to Your Admin Area and Broken Plugin or Theme.

If this does the trick, reactivate your plugins and themes one-by-one and check if the error reappears between each activation. When the error comes back, it means the last plugin or theme you activated is the cause of the problem.

You can contact the plugin or theme author for a fix if this does the trick.

Reset the .htaccess File

To manually reset the .htaccess file, first access the file through FTP.

Download a copy of the file onto your computer, then edit it in a compatible text editor. Once you finish editing it, save the file and upload it back to your server.

Alternatively, you can edit the file directly in an FTP client that has this feature such as FileZilla.

Open the file and replace the default code with the default code that’s relevant to your setup, then save the file. The code you need to replace should look similar to the snippets below.

For single installations of WordPress, copy and paste this into the document:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
view raw.htaccess hosted with ❤ by GitHub

For subdirectory installations of WordPress Multisite, use the code below:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
view raw.htaccess hosted with ❤ by GitHub

If you have a subdomain install of WordPress, use this code instead:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
view raw.htaccess hosted with ❤ by GitHub

On the other hand, if you have version 3.4 of WordPress or below installed, refer to the WordPress Codex’s .htaccess page for the code you need.

Once you have saved the file and it’s on your server, the error should be resolved, but you can continue trying the troubleshooting steps below if the issue persists.

Upgrade Your PHP Version

Using a version of PHP that’s incompatible with the version of WordPress you have installed often creates this error. Upgrading your version of PHP can often resolve this issue.

For details, check out one of our other posts Changing or Updating Your Version of PHP for WordPress.

Verify the Database Prefix

Sometimes, migrating your site from a local environment to a live server can create a discrepancy in your database table prefix.

To fix it, you need to check the prefix that’s written in your wp-config.phpand check it against the prefix that’s listed in your database. Be sure that the prefixes in both the wp-config.php file and the database contain all lowercase letters for any that are included.

Be sure to double check the values for the wp_capabilities and wp_user_level columns in the wp_users table for the correct prefix.

It’s also important to check the wp_usermeta table for incorrect references to the prefix you chose in the meta_key column. Then, look over the wp_options table for incorrect references in the values for the option_name and wp_user_roles columns.

It may be important to note that the prefix you see may be different from the default wp_ prefix mentioned above in cases where you previously changed your database prefix.

If you need to change the prefix in your wp-config.php file or database, check out Changing Your WordPress Database Prefix to Improve Security.

Database Admin Privileges

A possible cause for the error could also be improper user capabilities that are set up in the database. It’s important that the data in the wp_uerstable is correct.

Keep in mind that the prefix in your database may be different from the default wp_ mentioned above.

For details, check out How to Manually Add a WordPress Administrator to the Database using SQL Queries

Export Your Site Content

You can choose to export all the content on your site if none of the troubleshooting options above work for you. Then, you can import your content to a fresh install of WordPress to bypass the error.

You can also try this if you don’t have time to troubleshoot the issue.

For details, check out A Step By Step Guide to Moving Content From One WordPress Site to Another and How to Easily Import or Export any of Your WordPress Database Table Content.

Reset WordPress

After backing up your site, you can try resetting WordPress to its default settings. This can be done manually through dropping the tables in your site’s database via phpMyAdmin.

Keep in mind that if you drop all your WordPress database tables, you’re also going to lose all your posts, pages, comments and other content so use this option as a last resort.

For details, check out How to reset WordPress website? Both Using Plugin and Manually.

Wrapping Up

The “Sorry, you are not allowed to access this page” error can often be frustrating since you’re told you don’t have permission to view a page when you’re the admin for crying out loud!

Fixing it can also be frustrating since there are many probable causes. By following the troubleshooting steps above, you can resolve this issue quickly and efficiently.


(By niniane)

Leave a comment