Fix WordPress “Sorry, you are not allowed to access this page.”

I recently came across an issue with my WordPress installation. It’s situated behind a load balancer where SSL is terminated. The load balancer takes HTTPS traffic, then forwards it as HTTP on port 80 to the wordpress server.

I was running issues with a redirect loop after installing wordpress. The solution was to add this bit of code to wp-config.php:

define('FORCE_SSL_ADMIN', true);
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')

This solves the redirect loop issue but then I ran into a different problem. When I tried to sign into wp-admin I would get this message:

Sorry, you are not allowed to access this page.

After much digging I found this post which emphasizes that you must place that code BEFORE anything else in wp-config.php (except for the beginning PHP tag.) Success!

35 thoughts on “Fix WordPress “Sorry, you are not allowed to access this page.””


    I’ve spent two hours with this issue and this is the answer! Just to clarify the code needs to go after <?php in wp-config.php. You have a typo saying its wp-admin

  2. Hi Nicholas,
    I am the admin of the WordPress website and everything seems to be working fine when i access the dashboard.
    However when i access the website through the editor profile the editor does not seem to have permission to make changes on the page etc. I cant even access the dashboard as an Editor. I am sometime able to access the back end of certain pages, however after i make the changes and click update i get a message saying i do not have sufficient permission to make these changes. I wonder why this is happening. I dont get editor privileges. Same thing happens with Author and so on.
    I have also added the ‘User Role Editor’ Plugin, but i still get that lack of permission message.

    Does you have any thoughts on how this can be rectified?

    1. I’m not sure what it could be. If everything works for the admin I’m inclined to think it’s some sort of permissions issue for the user. What if you make a brand new user with those permissions?

  3. For anyone who is trying to use docker on a vps and running into this problem I’m writing some keywords here so hopefully when you do a search you’ll find this page. You’ll also possibly get a redirect loop error.

  4. After hours and hours (days even) trying to figure this out…

    This is the solution.

    Just moved the code from the bottom of the config to the top and boom.

    Thanks a ton.

  5. Thank you, thank you, thank you.

    Tried everything from adding a new admin level user to disabling plugins (by renaming plugins directory), to changing file / directory permissions and even enabling beta WordPress installs. Nothing helped.

    This tip solved the problem!!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

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