Quick answer
WordPress shows “Sorry, you are not allowed to access this page” when your user account doesn’t have the capability the page needs. The usual causes are a plugin or theme update that changed permissions, a changed database table prefix after a migration, a corrupted administrator role, a security plugin rule, or an incompatible PHP version. Start by disabling plugins via FTP or WP-CLI, then check your role in the wp_usermeta table.
Key takeaways
- Back up files and the database before you change anything.
- Renaming wp-content/plugins (or wp plugin deactivate –all) quickly shows whether a plugin is the cause.
- After a migration, a mismatched table prefix in wp_usermeta is the most common cause.
- WP-CLI can reset your role in one command: wp user set-role yourname administrator.
- Restore a backup only after the quicker fixes fail.
You log in to WordPress and, instead of the dashboard, you see a plain page: “Sorry, you are not allowed to access this page.” It often appears right after an update, a migration to new hosting or a change to a security plugin. The good news is that it is almost always fixable in a few minutes without losing content. Work through these fixes in order.
What causes “Sorry, you are not allowed to access this page”?
WordPress checks your user’s capabilities before showing any admin screen. The message appears when that check fails. Causes, from most to least common:
| Cause | Typical trigger |
|---|---|
| Plugin or theme conflict | An update changed or removed capabilities |
| Database table prefix mismatch | Migration, staging push or changed $table_prefix |
| Administrator role corrupted or removed | Role-editor plugin, hack, faulty update |
| Security plugin rule | Wordfence, iThemes/Solid Security, IP or country block |
| PHP version incompatibility | Host upgraded PHP; old plugin code fails |
| Wrong file permissions or corrupt core files | Failed update, manual uploads |
Fix 1: Back up first
Download the site files and export the database from your hosting panel (or run wp db export) so every change below is reversible.
Fix 2: Deactivate all plugins
Using FTP, SFTP or your host’s file manager, rename wp-content/plugins to plugins-off. Or with WP-CLI:
wp plugin deactivate --allTry logging in again. If it works, rename the folder back and reactivate plugins one at a time until the message returns. That plugin is the cause: update it, replace it or contact its developer.
Fix 3: Switch to a default theme
Rename your active theme’s folder in wp-content/themes, or run wp theme activate twentytwentyfive. WordPress falls back to a default theme. If you get in, the theme is the problem.
Fix 4: Check the database table prefix
Open wp-config.php and note the prefix, for example $table_prefix = 'wpx7_';. In phpMyAdmin, check two places use the same prefix:
- In the
wpx7_optionstable, the option name must bewpx7_user_roles. - In the
wpx7_usermetatable, keys must bewpx7_capabilitiesandwpx7_user_level, notwp_capabilities.
Rename any keys still using the old prefix. This is the fix for most “after migration” cases.
Need a website that turns visitors into enquiries?
My team builds fast, secure, SEO-ready websites and web apps for growing businesses.
Fix 5: Restore your administrator role
With WP-CLI:
wp user list --fields=ID,user_login,roles
wp user set-role yourname administratorWithout WP-CLI, in phpMyAdmin find your user ID in wp_users, then in wp_usermeta set wp_capabilities for that ID to:
a:1:{s:13:"administrator";b:1;}and wp_user_level to 10. Use your real prefix instead of wp_.
Fix 6: Check your security plugin and server rules
Temporarily rename the security plugin’s folder. Also check .htaccess for rules that deny wp-admin to your IP, and your host’s firewall or ModSecurity logs if you were recently blocked.
Fix 7: Check the PHP version and error log
In your hosting panel, see which PHP version the site runs. Current WordPress works best on PHP 8.3 or newer. Turn on logging in wp-config.php:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );Reload the page and read wp-content/debug.log. Errors naming a plugin or theme file point straight to the culprit. Turn debugging off afterwards.
Fix 8: Reinstall WordPress core files and check permissions
Run wp core download --force --skip-content, or upload fresh wp-admin and wp-includes folders from wordpress.org. Typical permissions are 755 for folders and 644 for files, with wp-config.php at 600 or 640.
What if nothing works?
Restore the most recent backup from before the problem started, then repeat the update or migration carefully on a staging copy. If the site was hacked (unknown admin users, strange files), clean it before restoring access.
How do I prevent this error?
- Test plugin and core updates on a staging site first.
- Use a migration tool that handles the table prefix, or search-and-replace prefixes deliberately.
- Keep at least two administrator accounts with strong passwords and two-factor login.
- Keep daily off-site backups.
Frequently asked questions
Why do I get “Sorry, you are not allowed to access this page” as an administrator?
Your account’s capabilities are missing or unreadable. This usually happens after a plugin update, a database prefix change during migration, or a corrupted administrator role.
Can a plugin cause the not allowed to access this page error?
Yes. Plugins that manage roles, memberships or security, and plugins with bugs after an update, are common causes. Deactivating all plugins via FTP or WP-CLI is the quickest test.
How do I fix it after migrating WordPress?
Make sure the table prefix in wp-config.php matches the prefix used in the user_roles option and in the capabilities and user_level keys in the usermeta table.
Will I lose content fixing this error?
No. Content is stored in the database and is not affected by deactivating plugins, switching themes or fixing roles. Take a backup first anyway.