Fix Drupal Website Not Loading

By Jimmy Bonney | December 2, 2013

Loading

Our company website runs on Drupal. The CMS is feature complete and the number of available modules allows to easily find a solution to almost any requirement. To sum it up, Drupal is great but, as any available technology, it doesn’t come without drawback.

While we were performing a website update two weeks ago, our hosting provider (which I prefer not to name but you can probably easily find out) had a network issue. As a result, the complete website went down for 4+ hours. While this is really annoying, it was only a start.

When the site came back online, Drupal was just not behaving properly at all. It was as if only part of the framework was working normally. Going to any page would display a 404, trying to log in to the admin interface would only go so far as prompting for the username and password, and the home page layout was there but no content could be seen whatsoever and the only “clue” available was the generic message “The requested page could not be found”.

I’ll pass the gory details of the investigation and the different steps that I had to get through to identify where the error was coming from but here are the final operations that allowed me to fix the issue.

Run Drupal Update

Update the sites/default/settings.php file to allow updates to be run by anybody. This is done by switching the line

1
$update_free_access = FALSE;

to

1
$update_free_access = TRUE;

Once this is done, simply go to your website URL followed by update.php, for instance http://example.com/update.php. In my case, this resulted in an error as illustrated below.

Drupal Update Error

Fix Incorrect Key File for Table

Trying to follow the instructions given on screen won’t get you far. The SQL command that is given is barely a SELECT command so this isn’t going to fix anything.

In addition, if you have a large database, the query itself might not even return anything before a long time (if it returns). However, it provides information about the table that is causing the problem. In this specific case, it was the menu_router table as illustrated below.

Drupal Update Error

Rebuild Drupal Menu

Based on this, Google allowed to find a fix. This is documented in details on Drupal Community Documentation and the fix consist in forcing the menu to get rebuilt. This is achieved by editing the function menu_execute_active_handler() in the file includes/menu.inc. Replace the following block:

1
2
3
if (variable_get('menu_rebuild_needed', FALSE)) {
  menu_rebuild();
}

by

1
2
3
//if (variable_get('menu_rebuild_needed', FALSE)) {
  menu_rebuild();
//}

Then access your website normally at http://example.com and everything should be back to normal.

Cleanup

Once everything is back to normal, do not forget to:

  1. Reset the $update_free_access variable to FALSE in sites/default/settings.php
  2. Uncomment the if statement in includes/menu.inc

Final Word

We have been clearly unlucky with this issue as it is a combination of the site going down while we were performing maintenance operation that (most probably) caused the menu table to be corrupted. In any case, this is what is making me consider more and more to move back to a static website with some dynamic pages only where needed. This would limit the risk of such event happening again but this is another story.



For the time being, comments are managed by Disqus, a third-party library. I will eventually replace it with another solution, but the timeline is unclear. Considering the amount of data being loaded, if you would like to view comments or post a comment, click on the button below. For more information about why you see this button, take a look at the following article.