Bobcares

Tired of Drupal admin access denied error? Here’s how to fix it

by | Oct 10, 2018

For as long as Drupal has existed, users have seen this error one time or the other:

Access denied

You are not authorized to access this page.

It might have appeared after a site migration, a server update or for no reason at all.

Drupal admins won’t be able to login to the admin panel, and no amount of cache clearing, or browser restarts would solve the issue.

Here at Bobcares, our Support Engineers help Drupal users fis such errors as part of our Outsourced Tech Support service for web hosting providers.

Today we’ll take a look at the top 5 causes we’ve seen for Drupal’s “Access denied” error when accessing the admin area.

Drupal admin access denied error

The error message is cryptic, which is all the more frustrating.

 

What is Drupal Admin access denied error?

A Drupal site admin can access all pages, and change any setting.

This is like having a super power over the site.

And how does Drupal make sure hackers won’t get that power?

By using something called “sessions”.

When an admin user logs in, that login is stored in a “session” file in the user’s browser as well as the website’s database.

As long as the session in these two locations remain accessible, the admin will have access to the site.

If the session details are lost or inaccessible in any of these two locations, Drupal will suspect a foul play and deny access to the pages.

So, how do session files become inaccessible? Read on.

 

Causes of Access denied error, and its solutions

Drupal depends on PHP, Databases, server file system, browser cache, and more to keep track of session files.

Even if one of them fails, the session tracking breaks, and Drupal will show the Access denied error to be on the safe side.

Here are the top 5 causes we’ve seen for this error:

 

1. Corrupted sessions table in the Drupal database

Drupal stores the session details in its database, within a table called “sessions”.

In busy websites, this table will have hundreds of even thousands of writes & reads, which can eventually cause the table to be corrupted.

Once it is corrupted, Drupal can no longer access it.

This will cause all open sessions to fail, including that of the admin.

Evidence of this issue can be seen in the log files. The error will state something like : Can't open file: 'sessions.MYI'

Solution : To fix this we repair the corrupted table with the command : mysql> repair table sessions;

 

2. Incorrect $cookie_domain setting in settings.php

Drupal uses small text files called “cookies” to store session information in the browsers.

This session information contains the website name as well, which is set using $cookie_domain in settings.php.

We’ve seen $cookie_domain set wrongly after a template export, website migration, or hosting update (say subdomain to standalone).

When the domain name used in the access URL is different from the domain name set in $cookie_url, Drupal shows Access denied error.

Solution : One way to fix this is to set $cookie_domain as “127.0.0.1” or “localhost”, which will cause Drupal to ignore that setting and use cookies based on each individual access.

 

3. PHP configuration errors

Website migrations can mess up Drupal dependencies.

For eg. Drupal requires a setting called “magic_quotes_gpc” in PHP to set to OFF.

But different servers configure this setting in different places. Some allow it to be specified in .htaccess, and others in a custom php.ini file. Some servers will need a mod_php based configuration, others might need suPHP based configuration.

We’ve seen customers trying to import their old PHP settings to a new server without customizing for the new environment.

Solution : There’s no single solution to this. When faced with such an issue, we inspect the log files, find out which PHP setting is blocking access, and rewrite the old setting to match the new environment.

 

4. PHP – Drupal version conflicts

Drupal is a pretty stable website platform, which meets almost all needs of an average business owner.

A downside of this stability is that people never upgrade to new versions.

The latest version of Drupal is v8, but we’ve seen sites still running Drupal 6 or even Drupal 5.

But web hosts will keep upgrading their PHP every few months or every year. We’ve seen these newer versions of PHP conflicting with older Drupal causing functions to fail.

Solution : When we see a Drupal site showing this error immediately after a server update, or after a migration, we look at the logs for deprecated function errors. If we detect version conflicts, we either help the user upgrade their Drupal or setup multi-PHP handlers so that the user can continue using the old PHP version.

 

5. Theme or module installation issues

Drupal puts theme and module files in a Cache to speed up the site.

We’ve seen sites break after a new theme or module installation. This is caused by stale cache messing up the site access.

One way to fix this is to clear the tables cache, cache_bootstrap, cache_block and sessions.

If that did not fix the issue, we then disable all modules and themes via the database, and enable only the default theme.

Then we enable each module one by one and bring the site back to the pre-update state.

 

There’s more – File permissions, incorrect security settings, etc..

Drupal admin access denied errors can happen due to a lot of other reasons as well.

It includes incorrect file and directory permissions, incorrect PHP security settings, web server misconfiguration and more.

So, if you are still facing the Access denied error, click here to talk to our Drupal experts. We are online 24/7 and come to your help in a few minutes.

 

Conclusion

Drupal admin access denied error is caused by database errors, incorrect Drupal settings, PHP config errors, and more. Today we’ve covered the top 5 causes for this error, and how to fix them.

 

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

SEE SERVER ADMIN PLANS

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF