Last updated December 6, 2014. Created on November 26, 2007.
Edited by nitishchopra, bigjim, gagarine, Tor Arne Thune. Log in to edit this page.

What is the maintenance page?

The maintenance page is used when the site is set in off-line mode or the site is inoperable due to technical problems, such as a database failure. You can enable this mode from "Administer > Site configuration > Site maintenance". This mode will also trigger during a database failure. By default, the core theme Minnelli is used in this mode even if another theme is selected. However, you might like to include a maintenance page from within your own site.

Overriding template files in Drupal

Creating a custom theme in Drupal is a practice of overriding existing template (.tpl.php) files. You can find template files included with the core distribution and you can either copy these files into your theme folder, or create new files with the same name. Drupal will first choose your theme's template files before the core ones. In this way, you can override the default templates. For example, there is a maintenance-page--offline.tpl.php file which exists in Drupal core, that you can duplicate into your own theme.

Sometimes you can use template suggestions, which means example files don't exist with Drupal, but if you include a file with the suggested name, Drupal will pick it up. For example maintenance-page.tpl.php doesn't exist in core, but you can create a file with that name and Drupal will recognize it.

In this case there are two maintenance page files that you can create. You can duplicate your theme's page.tpl.php twice and name them:

  1. maintenance-page.tpl.php: This file controls the page that is displayed when the site is in "maintenance mode" but the database connection and database are still functioning correctly.
  2. maintenance-page--offline.tpl.php: This file controls the page that is displayed when Drupal cannot access the database (for whatever reason).

Step 1: Override the maintenance page template

Copy your main page.tpl.php and rename it to maintenance-page.tpl.php or copy the template located in modules/system/maintenance-page.tpl.php to your theme and edit so it matches the rest of your site.

Step 2: Indicate in your settings.php file

In the case of a database failure, your maintenance page setting must be indicated in configuration files so this can operate without access to the database. Specify your maintenance page in your settings.php file, which is usually located at sites/default or sites/ (if you are on a multi-site installation).

Option 1

In the settings.php file, enable the $conf variable with the internal name of your theme:

  $conf['maintenance_theme'] = 'themeName';

Option 2

In the settings.php file, numerous configurations are disabled with a # (hash) symbol at the start of the line. You can remove the # symbol at the start of the line to uncomment and enable that configuration.

Therefore, instead of adding the line as in Option 1 above to the settings.php file, you can also uncomment the relevant lines in settings.php. In that case, you have to uncomment 3 separate lines:

  • The array declaration (# $conf = array()
  • The maintenance theme setting (# 'maintenance_theme' => 'minnelli',)
  • The closing parenthesis (# );)

Verify the changes by setting the site into off-line mode then log out.

To account for database failures, try turning off your database. Any function call that depends on the database should be checked first with db_is_active. The variable $db_is_active can also be used from the template.

As an alternative to disabling your database, force a database connection failure. Examples for both methods can be found here.

Step 3: Create the maintenance offline page in the case of database failure

To prevent warnings about the database connection from appearing, copy your page.tpl.php file and rename it maintenance-page--offline.tpl.php. Change the $content variable with your custom message. Note, this template file is a template suggestion based on maintenance-page.tpl.php so they both need to exist in the same folder.

At the top of maintenance-page--offline.tpl.php, you might also want to set the following variables detailed in step 4.

Step 4: Hard code site settings

In this mode, your database is inaccessible, therefore some key settings about your site are not available. If you want this page to use the same theme and other settings that the site would normally use, you must replicate those settings by using hard-coded values.

Copy these variables into the maintenance-page--offline.tpl.php file:

  • $head_title - the value used in the HTML <title> tag. Defaults to "Site off-line | Drupal"
  • $site_name - the value used in the page's <h1> tag. Defaults to "Drupal". If "Site name" is turned off in your theme configuration, then you'll want to clear this variable (see example below).
  • $logo - if you're using a custom logo override in the theme settings. Use the full path of the custom logo, relative to the base directory of the Drupal installation. If you used the standard override upload function in the theme configuration for your custom logo, your logo will be stored in sites/all/files/ (see example below).
  • $site_slogan - your site's slogan. If "Site slogan" is turned off in your theme configuration but you still have a site slogan defined in Site Information, then you'll want to clear this variable (see example below).

Example additions at the top of maintenance-page--offline.tpl.php:

  $head_title = ' :: Site-offline';
  $logo = 'sites/all/files/customLogo.png';

  // If your theme is set to display the site name, uncomment this line and replace the value:
  // $site_name = 'Your Site Name';

  // If your theme is set to *not* display the site name, uncomment this line:

  // If your theme is set to display the site slogan, uncomment this line and replace the value:
  $site_slogan = 'My Site Slogan';

  // If your theme is set to *not* display the site slogan, uncomment this line:
  // unset($site_slogan);

  // Main message. Note HTML markup.
  $content = '

The site is currently not available due to technical problems. Please try again later. Thank you for your understanding.

If you are the maintainer of this site, please check your database settings.


A maintenance.css file is included in this mode. It is located in modules/system/maintenance.css. You can override this file with the instructions provided in the style sheets section.


  • The initial install and updating of your site depends on the core themes, Minnelli and Garland. It cannot be changed for these modes.
  • The theme registry is not cached when set to off-line mode.
  • Ensure that the theme used as maintenance theme is enabled (Administer > Site building > Themes).

Looking for support? Visit the forums, or join #drupal-support in IRC.


SDM-MINK’s picture

I am new to Drupal, so I am probably making a mistake. I am trying to change the Theme of my Drupal 6 maintenance page so that it matched the theme (mytheme) that I am using for my site (Theming the Drupal 6 maintenance page -

I tried to followed the instructions shown in Here are the problems that I had:

1. Got message that sites/default/settings.php was password protected so that I could not make changes to this file. So I made changes to the sites/default/default.settings.php. However, when I went to upload the modified file onto my server, I received a message indicating that sites/default/ was locked and thus would not accept this modified file.

2. Am I to save the new file maintenance-page.tpl.php in theme/mytheme or write over the file located in modules/system?

3. I could not find any directions as to how to modify modules/system/maintenance.css. I assume that I should take my style.css (in theme/mytheme), rename it maintenance.css then write over the file located in modules/system. Is this correct?

However, since I could not perform 1 above, I am still using the default ("minnelli") maintenance page.

Any assistance is much appreciated! Thanks!

mattyoung’s picture

The settings.php file is write protected for security reason. You need to temporarily turn on write permission to that file to make change. On Unix/Linux you would do chmod u+w settings.php, edit/save, then chmod u-w settings.php.

annicole72’s picture

hi, how do you turn off the database?


SDM-MINK’s picture

Do you mean "turn off the theme & turn on the maintenance page" or "turn off the maintenance page"?

gateone’s picture

I guess you mean "how do I turn off the database to see what happens to my site". In order to do that, you really would need full server access, it usually cannot be simulated with typical shared hosting plans.

On a dedicated server: if you use the Plesk control panel, you can go to Server -> Services and switch off MySQL. Don't worry about Plesk, it runs on its own DB-server and own Webserver, so whatever happens, Plesk should remain accessible. If you don't run a control panel, you need to log in as root via SSH (or do it locally in the terminal if you have physical access to the server). Then issue

/etc/init.d/mysqld stop

The Database server will shut down and tell you so. Now you can test your Drupal installation and test what happens if no DB-server can be found any more. The normal and unaltered behaviour of Drupal is to spit out a page in the standard maintenance design saying that such and such database on server such and such with username such and such (sic!!!) is not available.

Thanks god Drupal does not tell the database password!!! This is a good ment feature for the site admin in case things go wrong (like the DB server died by some reason) but it is a bit awkward on public and live sites where such things might also happen... I mean you don't get far with this information, but non-the-less, the general public now knows where the database server is located, what Drupal's database is called and which username is chosen to access the server... :-(

This is basically the reason why DB-offline maintenance themes should be done on larger scale sites. To provide a clean information that something has gone wrong. :-)

After your test (seeing if your new DB-offline page actually works in such situations), don't forget to switch back on the DB-server, either using Plesk or on the command line with

/etc/init.d/mysqld start

Just as a note: should in your distro the terminal tell you that there is no file in /etc/init.d called mysqld, you might want to search for it on the machine, it will usually be somewhere in a subdirectory that controls the services to start upon system startup. On some Linux systems, there is the even more elegant command

service mysql stop
service mysql start

kentr’s picture

Instead of actually disabling the database, you can just intentionally cause a failed connection.

Do this by making the connection string invalid in settings.php:

  • At the very bottom of the file, add:
    $db_url = 'x';

This should cause a failed database connection and invoke the maintenance-page-offline.tpl.php file.

When you're done testing, remove that code. It should set everything back to normal.

eff_shaped’s picture

You can change permissions to settings.php another way (if, like me, you don't get involved with all that unix/linux voodoo).

- Log in to your cPanel or file manager

- Find sites/all/default/settings.php

- The file permissions are probably set to 0644.

- Change these to 0777 and you can overwrite the file.

- Remember to change them back to 0644 afterwards.

Anthony Pero’s picture

You can change permissions with almost any FTP client by right clicking (cmd+click on OS X) and selecting permissions, or properties, or whatever it is called in your program.

Anthony Pero
Project Lead
Virtuosic Media

cabplan’s picture

I have tried all these steps but the problem I am running into is that I cannot overwrite the settings.php file. I am using FileZilla and I change the permissions to a 777 but it still says permissions denied. I have overwrote the /modules/system/maintenance-page.tpl.php with my page.tpl.php code but that did not change anything. I also added a maintenance-page.tpl.php to my theme but that did not change the offline maintenance page on my website. I even created the maintenance-page-offline.tpl.php page and added to my theme but still does not change.

Does anyone know a simple way to change the "Site off-line" page? I tried following these instructions on: but everything still looks the same.

cabplan’s picture

Ok I found what I was doing wrong, I had to change the permissions of the default folder not just the settings.php file.

Anthony Pero’s picture

Make sure you get a clean copy of /modules/system/maintenance-page.tpl.php and put it back to normal. You don't ever need to alter this file. The copy in your themes folder overrides this copy, just exactly the way a css style rule lower in a css document will override the exact same rule earlier in a document.

Anthony Pero
Project Lead
Virtuosic Media

mayle’s picture

Hi everyone!

I managed to change the maintenance theme to Garland by modifying the "settings.php" file as described above (
However, the appearance of the off-line maintenance site is still different as the on-line color scheme - specified within the color module - is not reflected.
Instead the standard blue lagoon appearance is shown on the screen.

Is there any simple way of adapting this?
I just would like to use the same color settings for the maintenance theme as for the standard theme - nothing sophisticated so.
I have been searching for several days now, but I still do not have any clue on how to achieve this.
Probably, this can be done fairly easy by copying a stylesheet file somewhere... (I am new to Drupal, sorry!)

Any help would be much appreciated. Thanks a lot!

mattyoung’s picture

The problem is the color settings are *not* processed for the maintenance page. You can make a little modification to Garland to make the color change happen. In Garland's template.php, add this function:

phptemplate_preprocess_maintenance_page(&$vars) {

This will work for site off-line mode. But it will not work when database is not working. To get that working also, you will need to set the variable 'color_garland_stylesheets' array in $conf[] inside settings.php to reflect your current color module settings and you need to edit that everytime you make color change.

To learn more about maintenace page theme, see

mayle’s picture

Thank you for the quick reply!

I had to add the word "function" in the declaration part. I guess that is okay, because otherwise Drupal returned an error message.
Unfortunately, the added function did not have any effect - I still get the Blue Lagoon appearance of the maintenance theme.
Am I missing anything?

Concerning your second remark, what exactly do I have to specify for 'color_garland_stylesheets' inside "settings.php"?

$conf = array(
  'color_garland_stylesheets' => 'sites/default/files/color/garland-f2968754/style.css',

Apart from the stylesheet path, I also tried the respective color values and a boolean variable so far. However, none of them seemed to work as I always get some kind of error message even with the database still working.

mattyoung’s picture

change the function to:

function phptemplate_preprocess_maintenance_page(&$vars) {
  if (function_exists('_color_page_alter')) {

This will work for site off-line mode. However, I haven't found a way to make it work for database is off case. It will still be in the default color scheme.

mayle’s picture

Thank you very much for your help!

Concerning the case when the database is offline, you made the following remark some posts earlier:
"This will work for site off-line mode. But it will not work when database is not working. To get that working also, you will need to set the variable 'color_garland_stylesheets' array in $conf[] inside settings.php to reflect your current color module settings and you need to edit that everytime you make color change."
As I am not planning to make frequent (perhaps not even any) color changes, I would like to try setting the variable 'color_garland_stylesheets'. However I do not know which value to assign - stylesheet path, color values, etc.
Have you got any idea on this? Sorry for bothering you again...

cgjohnson’s picture

Thank you for this information, this is very helpful!

Still, it seems to me it should be a lot easier to have your maintenance page connect with your site's theme. Any plans for this functionality to become core -- e.g., so admins can chose a site maintenance theme without having to do anything to the php? I will submit a feature request as well.


mattyoung’s picture

>it seems to me it should be a lot easier to have your maintenance page connect with your site's theme

This is pretty much impossible because maintenance page need to work when the database is offline. With the database gone, drupal basically have to work in its most primitive mode and all normal settings information are not available. The only facility have in that case is settings.php and there no way around it.

eff_shaped’s picture

I have a couple of doc improvement suggestions:

Can you break it down into steps more clearly?
And separate the simple first stages (settings.php and maintenance-page.tpl.php) from the more complex that follow?
Subheadings would help with structure.

I managed to make my offline message look more like I want it. So, thank you.

kentr’s picture

Please edit the page if you can make it more clear for people.

Militopedia’s picture


I tried to change the theme for the off-line maintenance page according to

I added one line to the sites/default/settings.php file

<?php $conf['maintenance_theme'] = 'nitobe'; ?>

but got the error message:

Fatal error: Cannot redeclare gnf2() (previously declared in /home/mypage/public_html/index.php(1) : eval()'d code:1) in /home/mypage/public_html/sites/default/settings.php(1) : eval()'d code on line 1

After I removed the statement again from the settings.php file I still have this error message and cannot access my page anymore.

I hope somebody can help me out! I am at the end of my wisdom.


00110000’s picture

Check your setting.php file permissions. Make sure it's actually still writable. Apparently you're not overwriting the one up on your server.

wwwoliondorcom’s picture

Thank you, but is there any new easy way to change the mySql unable to connect page now ?

I tried to to it the way it is explained here and got an error:

Parse error: syntax error, unexpected T_FUNCTION in /sites/default/settings.php on line 241

Any help ?

Thanks a lot.

00110000’s picture

Believe it or not, this method is very very easy. It's just a tad bit confusing at first (I was for one), due to the way it's explained on here.

So I'm just gonna go bare ones here. The only thing you're doing to the setting.php is the following:

Open up the settings.php file in something like Dreamweaver (i'm gonna go by line numbers).

On line 184, which contains: # $conf = array(

You remove the "#".

You then skim through and move on to line 196, which contains: # 'maintenance_theme' => 'minnelli',

You remove the "#".

And in place of "minnelli", you place the name of *your* theme. Which is where you want your customized maintenance-page-offline.tpl.php file in, so that you're able to to use it for database errors or unable to connect to a database etc.

You then skim through and move on to line 225, which contains: # );

You remove the "#".

Save settings.php and upload it viat ftp, but before you do, again make sure the current file up has it's file permission set to something like "777", so that you're able to save your new version.

Tada, you're done. It's really simple actually. It just seems complicated or confusing at first, due to being a bit unaware of how things function.

And if you want to see if it's working, as suggested above, simply place:

$db_url = 'x';

on the last line of settings.php

Once you're done testing that it works, don't forget to remove that line.

Friendly reminder: once you upload of the newer file and after you're done editing it, be sure to revert it's file permission to the way they were originally, which should have been: "444".

dropfoundry’s picture

did that...and got this

* warning: array_keys() [function.array-keys]: The first argument should be an array in /home5/dropfoun/public_html/includes/ on line 220.
* warning: Invalid argument supplied for foreach() in /home5/dropfoun/public_html/includes/ on line 220.

any ideas.

i'm tapped.


kentr’s picture

did that...and got this

There are a couple of concepts in the post to which you replied. What specifically did you do?

dropfoundry’s picture


True...I guess I didn't make myself clear. I followed the "Believe it or not" reply. I have actually changed the maintenance theme before using the same steps, but now, I'm running into this trouble.

Any ideas?


ronsnow’s picture

I am having the same problem where the resulting site offline page is getting the following errors:

* warning: array_keys() [function.array-keys]: The first argument should be an array in /home/geore2/public_html/mysite/includes/ on line 220.
* warning: Invalid argument supplied for foreach() in /home/geore2/public_html/mysite/includes/ on line 220.

I followed the instructions in this thread and verified my settings.php file is correct and verified that maintenance-page.tpl.php file exists (I also have the maintenance-page-offline.tpl.php file in place).

Did you ever figure this out? If so please post the solution.... Thanks

PragueBob’s picture

...same problem as you have, even though I followed the instructions verbatim, please let me know if you figure it out or get the answer from someone!

kayceedub’s picture

The file includes/ references the Minellli theme, which was not enabled on my site. Once I enabled it, the errors went away and I got it to use my theme.

kentr’s picture

Post the resulting code from the changes you made to the settings.php file (post the final code, minus any DB connection information or other security-related info). That will help identify errors.

mattg8’s picture

// $Id: default.settings.php,v 2009/09/14 12:59:18 goba Exp $

* @file
* Drupal site-specific configuration file.
* This file may have been set to read-only by the Drupal installation
* program. If you make changes to this file, be sure to protect it again
* after making your modifications. Failure to remove write permissions
* to this file is a security risk.
* The configuration file to be loaded is based upon the rules below.
* The configuration directory will be discovered by stripping the
* website's hostname from left to right and pathname from right to
* left. The first configuration file found will be used and any
* others will be ignored. If no other configuration file is found
* then the default configuration file at 'sites/default' will be used.
* For example, for a fictitious site installed at
*, the 'settings.php'
* is searched in the following directories:
* 1. sites/
* 2. sites/
* 3. sites/org.mysite.test
* 4. sites/
* 5. sites/
* 6. sites/org.mysite
* 7. sites/
* 8. sites/
* 9. sites/org
* 10. sites/default
* If you are installing on a non-standard port number, prefix the
* hostname with that number. For example,
* could be loaded from
* sites/

* Database settings:
* Note that the $db_url variable gets parsed using PHP's built-in
* URL parser (i.e. using the "parse_url()" function) so make sure
* not to confuse the parser. If your username, password
* or database name contain characters used to delineate
* $db_url parts, you can escape them via URI hex encodings:
* : = %3a / = %2f @ = %40
* + = %2b ( = %28 ) = %29
* ? = %3f = = %3d & = %26
* To specify multiple connections to be used in your site (i.e. for
* complex custom modules) you can also specify an associative array
* of $db_url variables with the 'default' element used until otherwise
* requested.
* You can optionally set prefixes for some or all database table names
* by using the $db_prefix setting. If a prefix is specified, the table
* name will be prepended with its value. Be sure to use valid database
* characters only, usually alphanumeric and underscore. If no prefixes
* are desired, leave it as an empty string ''.
* To have all database names prefixed, set $db_prefix as a string:
* $db_prefix = 'main_';
* To provide prefixes for specific tables, set $db_prefix as an array.
* The array's keys are the table names and the values are the prefixes.
* The 'default' element holds the prefix for any tables not specified
* elsewhere in the array. Example:
* $db_prefix = array(
* 'default' => 'main_',
* 'users' => 'shared_',
* 'sessions' => 'shared_',
* 'role' => 'shared_',
* 'authmap' => 'shared_',
* );
* Database URL format:
* $db_url = 'mysql://username:password@localhost/databasename';
* $db_url = 'mysqli://username:password@localhost/databasename';
* $db_url = 'pgsql://username:password@localhost/databasename';
$db_url = 'mydburl';
$db_prefix = '';

* Access control for update.php script
* If you are updating your Drupal installation using the update.php script
* being not logged in as administrator, you will need to modify the access
* check statement below. Change the FALSE to a TRUE to disable the access
* check. After finishing the upgrade, be sure to open this file again
* and change the TRUE back to a FALSE!
$update_free_access = FALSE;

* Base URL (optional).
* If you are experiencing issues with different site domains,
* uncomment the Base URL statement below (remove the leading hash sign)
* and fill in the absolute URL to your Drupal installation.
* You might also want to force users to use a given domain.
* See the .htaccess file for more information.
* Examples:
* $base_url = '';
* $base_url = '';
* $base_url = '';
* $base_url = '';
* It is not allowed to have a trailing slash; Drupal will add it
* for you.
# $base_url = ''; // NO trailing slash!

* PHP settings:
* To see what PHP settings are possible, including whether they can
* be set at runtime (ie., when ini_set() occurs), read the PHP
* documentation at
* and take a look at the .htaccess file to see which non-runtime
* settings are used there. Settings defined here should not be
* duplicated there so as to avoid conflict issues.
ini_set('arg_separator.output', '&');
ini_set('magic_quotes_runtime', 0);
ini_set('magic_quotes_sybase', 0);
ini_set('session.cache_expire', 200000);
ini_set('session.cache_limiter', 'none');
ini_set('session.cookie_lifetime', 2000000);
ini_set('session.gc_maxlifetime', 200000);
ini_set('session.save_handler', 'user');
ini_set('session.use_cookies', 1);
ini_set('session.use_only_cookies', 1);
ini_set('session.use_trans_sid', 0);
ini_set('url_rewriter.tags', '');

* If you encounter a situation where users post a large amount of text, and
* the result is stripped out upon viewing but can still be edited, Drupal's
* output filter may not have sufficient memory to process it. If you
* experience this issue, you may wish to uncomment the following two lines
* and increase the limits of these variables. For more information, see
# ini_set('pcre.backtrack_limit', 200000);
# ini_set('pcre.recursion_limit', 200000);

* Drupal automatically generates a unique session cookie name for each site
* based on on its full domain name. If you have multiple domains pointing at
* the same Drupal site, you can either redirect them all to a single domain
* (see comment in .htaccess), or uncomment the line below and specify their
* shared base domain. Doing so assures that users remain logged in as they
* cross between your various domains.
# $cookie_domain = '';

* Variable overrides:
* To override specific entries in the 'variable' table for this site,
* set them here. You usually don't need to use this feature. This is
* useful in a configuration file for a vhost or directory, rather than
* the default settings.php. Any configuration setting from the 'variable'
* table can be given a new value. Note that any values you provide in
* these variable overrides will not be modifiable from the Drupal
* administration interface.
* Remove the leading hash signs to enable.
$conf = array(
# 'site_name' => 'My Drupal site',
# 'theme_default' => 'minnelli',
# 'anonymous' => 'Visitor',
* A custom theme can be set for the off-line page. This applies when the site
* is explicitly set to off-line mode through the administration page or when
* the database is inactive due to an error. It can be set through the
* 'maintenance_theme' key. The template file should also be copied into the
* theme. It is located inside 'modules/system/maintenance-page.tpl.php'.
* Note: This setting does not apply to installation and update pages.
'maintenance_theme' => 'mytheme'
* reverse_proxy accepts a boolean value.
* Enable this setting to determine the correct IP address of the remote
* client by examining information stored in the X-Forwarded-For headers.
* X-Forwarded-For headers are a standard mechanism for identifying client
* systems connecting through a reverse proxy server, such as Squid or
* Pound. Reverse proxy servers are often used to enhance the performance
* of heavily visited sites and may also provide other site caching,
* security or encryption benefits. If this Drupal installation operates
* behind a reverse proxy, this setting should be enabled so that correct
* IP address information is captured in Drupal's session management,
* logging, statistics and access management systems; if you are unsure
* about this setting, do not have a reverse proxy, or Drupal operates in
* a shared hosting environment, this setting should be set to disabled.
# 'reverse_proxy' => TRUE,
* reverse_proxy accepts an array of IP addresses.
* Each element of this array is the IP address of any of your reverse
* proxies. Filling this array Drupal will trust the information stored
* in the X-Forwarded-For headers only if Remote IP address is one of
* these, that is the request reaches the web server from one of your
* reverse proxies. Otherwise, the client could directly connect to
* your web server spoofing the X-Forwarded-For headers.
# 'reverse_proxy_addresses' => array('a.b.c.d', ...),

* String overrides:
* To override specific strings on your site with or without enabling locale
* module, add an entry to this list. This functionality allows you to change
* a small number of your site's default English language interface strings.
* Remove the leading hash signs to enable.
# $conf['locale_custom_strings_en'] = array(
# 'forum' => 'Discussion board',
# '@count min' => '@count minutes',
# );

ebo1958’s picture

When I use 'maintenance_theme' => 'minnelli',
and use $db_url = 'x'; to test the site, a page announcing server problems shows up beautifully as expected. Unfortunately, when I replace the minnelli as follows:
'maintenance_theme' => 'litejazz', I get
Fatal error: Call to undefined function db_query() in /mnt/xx/xx/xxx/htdocs/horst/includes/ on line 609
In my settings.php:
$conf = array(
'theme_default' => 'litejazz',
'maintenance_theme' => 'litejazz',
are set.

The files maintenance-page.tpl.php and maintenance-page-offline.tpl.php are in my theme folder (litejazz).
Minnelli and Garland are active.
No optimized css.
No cache activated.

with 'maintenance_theme' => 'sites/all/themes/litejazz',
I get:
Warning: array_keys() [function.array-keys]: The first argument should be an array in /mnt/xx/xx/xxx/htdocs/horst/includes/ on line 220

Warning: Invalid argument supplied for foreach() in /mnt/xx/xx/xxx/htdocs/horst/includes/ on line 220
followed by the content when minnelli is set in settings.php and not the content of my maintenance-page-offline.tpl.php file.

It seems that when DB is turned off, my theme isn't being found.
Any suggestions?

mattyoung’s picture

This is probably because the litejazz theme makes database call in its template somewhere. Theme should never do this but I have seen some do. They should normally use variables supplied by preprocess functions.

ebo1958’s picture

Thanks for the quick reply. I haven't a clue what "variables supplied by preprocess functions" are or how to adapt this within litejazz. Decided on using "basic" and adapting that to my design. Works beautifully.

esharf’s picture

I know I'm a bit late to the discussion, but FWIW, the only solution that I found was to enter the theme name in lower case, not as a string literal. So

$conf = array(
'theme_default' => 'theme_name',
'maintenance_theme' => 'my_theme',

instead of:

$conf = array(
'theme_default' => 'Theme_name'
'maintenance_theme' => 'My_theme',

This is probably obvious to the experienced eye, but not to us newbies.

RytoEX’s picture

Seriously thank you! I was banging my head against the wall trying to figure this out, and putting the theme in lowercase did it. Thanks again!

pageturner’s picture

For anyone who is getting the

* warning: array_keys() [function.array-keys]: The first argument should be an array in /home5/dropfoun/public_html/includes/ on line 220.
* warning: Invalid argument supplied for foreach() in /home5/dropfoun/public_html/includes/ on line 220.

error. Make sure that your theme name is put in exactly the same way you named your info file. I had this error at first. I tried several of the suggestions but none of them worked for me. I found this suggestion here: and it worked!

Hope this helps someone.

verta’s picture

This helped a lot, and I have the planned outage screen themed. THANKS!

However, when I test the db being down with the $db_url string, I get an undefined variable and the theme's default logo.

It looks like to do this right, I need to spend some time with the customized maintenance-page-offline.tpl.php file and use the advice higher in the thread for $logo and make sure the variables references that rely on db access are removed or handled. I might let the theme's developer know about it, so he might create a customized maintenance-page-offline.tpl.php file for the theme.

chowdah’s picture

If the logo is hard coded into the theme, then add this line :
unset ($logo);
to the top of the maintenance-page-offline.tpl.php page content, otherwise do this to get the correct logo:
where "correct/path/to/theme/logo" is the actual url of the theme's logo.

digital76’s picture

Hey All,

I know this thread is a little old, but i'm hoping there is someone out there who can help me, I'm at my wits end with this process. I have followed these instructions to a T, multiple times, and every single time, I get the error:

Parse error: syntax error, unexpected T_DOUBLE_ARROW in /public_html/ on line 196

Line 196 is:

'maintenance_theme' => 'aperture',

So, I don't understand whats happening. When this error appears, I have to change my settings.php file back to default, so my site will show up at all, and my maintenance page is a completely different theme then the rest of my site.

I'm desperate. Thanks in advance for an help!


jamesrward’s picture

You need to uncomment the start of the array, the line for maintenance_theme and the end of the array. On my settings.php that means uncommenting lines 172, 184, and 213.

wobblefoot’s picture

Why on earth have Drupal's designers determined to re-theme my site for me at all? Why aren't site-maintenance templates (with simple assets ex-database) included in the themes spec? Why doesn't the theme-configuration page warn about this impressively unintuitive behaviour and why on earth can't we just add a URL to a static offline or "coming soon" page from here?

Most Drupal newcomers will follow the information that has been generously posted on this page, but why should they have to?

I'd love to know if there are any changes planned.

receive’s picture

They haven't re-themed your site. In the absense of a database the only place left to set the theme to be used for error pages is the settings file.

Similarly, you can't just add a static URL from the theme configuration page because that data is stored in the database, and the offline page needs to be displayed when the database is offline.

I'd love to see you propose some changes that actually make sense.

kentr’s picture

Only the database connection error page is served sans database. The regular maintenance page employs the database.

mattyoung’s picture

but the settings.php has the final say on what the variables values are. It overrides any values stored in the database.

kentr’s picture

There are many, many ways Drupal could be improved, but programmers prioritize their time (which is largely volunteer).

If you feel strongly about this issue, take it on and submit a patch, or hire someone to do the work. The latter is called "posting a bounty."

On the note of re-theming your site, your perspective is a bit skewed. The Drupal engineers have provided you with a default theme. It is you who is re-theming the site. These are the steps you must take to include the maintenance and offline pages in that effort. Given that re-theming is something that happens pretty rarely, it makes sense to put most effort into debugging and streamlining the day-to-day use aspects.

jgarbe’s picture

I've followed this, and it works fine, as long as people are going to or However, if they're going to just, it defaults to the minelli themed one...any ideas why this could be happening? Thanks!

carolalindh’s picture

Gets exactly the same result. Root displays a different theme but if you put anything after it chooses my theme... Really strange

RigorMortis’s picture


Had the same problem. After tearing my hair out (and writing a rather long post to this thread, but thankfully before posting it) I tried clearing the cached data (/admin/settings/performance) and lo-and-behold, the root URL fell into line.

*shakes fist at cache*

mechdrupal’s picture

hi everyone! good day, i'm new to drupal =)

[[ Next, copy your main "page.tpl.php" and rename it to "maintenance-page.tpl.php" or copy the template located in "modules/system/maintenance-page.tpl.php" to your theme and edit so it matches the rest of your site. Verify the changes by setting the site into off-line mode then log out. ]]

can any1 please elaborate the step-by-step instruction on this part above on what to really do here? it's a bit confusing...sorry...would be glad if any1 can assist. thanks! more power to drupal team...

verta’s picture

I found it more useful to make a copy of my theme's page.tpl.php as a new file called maintenance.tpl.php than to use the system-provided maintenance.tpl.php. Recommend that the doc have this as an option. It set the styles for the header correctly and included the footer appropriately as well.

chowdah’s picture

It's all good except that the maintenance-page-offline.tpl.php is displaying the MySQL errors before rendering the template. I like to have the MySQL display errors on when there are errors, but I would like to shut them off just for this page, because the fact that this template is being used is already a testament to MySQL errors! If I use ini_set('display_errors','0'); on the template page, it's too late because the errors are generated before the template is included. Is there any way around this?

kentr’s picture


You may know this and be intentionally choosing otherwise or have a special situation, but just in case:

It's generally a bad idea to display raw errors to users on production sites. Most errors can be logged in the DB or syslog with some optional modules so you still have access to them w/o displaying them.

onkiro’s picture

"A "maintenance.css" file is included in this mode. It is located in "modules/system/maintenance.css". You can override this file with the instructions provided in the style sheets section. "

overriding the core included file is not the first option in my opinion. In case of a core update the modified file will be gone.
As assumend in the comments, copy your style.css and rename it into maintenance.css. Leave this .css file in your custom theme directory and leave the core maintainance.css untouched.
This way you are safe in case of any updates.

lance1572’s picture

I'm trying to overide my maintenance.css file. Here's what I did.

1. Copied over the maintenance-page.tpl.php
2. changed the settings.php
3. Copied the maintenance.css over to my themes folder = sites/all/themes/mytheme
4. Added the maintenance file to the .info file - stylesheets[all][] = css/maintenance.css

My question is - is this the right way to add it into the .info file? Specifically, the [all]. I noticed that indeed it is included in the source - when I view source in Firefox. But on viewing my maintenance page I still see it has the background design of my live on-line mode site. So it is taking in some styles. So how can I totally strip out the style and start with a blank page?


ycwjjjj’s picture

In my case, maintenance-page.tpl.php can work fine to display new themed site offline page but not maintenance-page-offline.tpl.php.

When there is or there is not maintenance-page-offline.tpl.php in own theme directory, the following errors shown instead of showing a page like the themed Minnelli database error page.

Anyone can help for this? Thanks!

Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in /.../includes/ on line 382

Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in /.../ on line 382

Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /.../includes/ on line 114

Warning: mysqli_errno() expects parameter 1 to be mysqli, null given in /.../includes/ on line 135

Warning: mysqli_affected_rows() expects parameter 1 to be mysqli, null given in /.../includes/ on line 213

Warning: Cannot modify header information - headers already sent by (output started at /home/content/q/a/i/qaiai/html/includes/ in /.../includes/ on line 883

Fatal error: Call to undefined function user_access() in /.../sites/all/themes/fusion/fusion_core/template.php on line 69

Fatal error: Call to undefined function lock_acquire() in /.../includes/ on line 561
manero24’s picture

I had the same problem and since it seemed to be Theme related, I put my site back online, then disabled the Optimize CSS files cache under Performance and put my site offline again. My site offline page now looks great. Don't forget to re-enable your CSS files cache optimization afterwards. I suppose that Clearing the cache would have done the trick as well.

dmf7’s picture

I did exactly as you described above.. ( I am using the acquia prosper theme) and I cleared the cache and it' works great! Thanks for posting that. it was very easy!. It displays my sites background image and logo.

My only issue though is that the offline message is not centered and looks weird. How do I change the css or positioning of it?

verta’s picture

You know, that is cool - thanks. Maybe cool enough for a core feature request? Put a check box under the radio group that is active when the site is offline to disable the CSS cache?

dmf7’s picture

I agree. this is great! I'm not seeing any radio buttons (or maybe I'm not looking in right place) but how do I disable the css cache? I'm not sure what you mean. does that change the position of the site offline text?

dmf7’s picture

I just realized you weren't specifying how to change the css, just asking for a feature.

does anyone know how to change the css or at least center the offline text?

dmf7’s picture

Ok so I used the advice from "Believe it or not " response and that worked perfect, kept my background and logo. The offline message is not centered properly and I want to change it it a bit. How do I go about doing that? I'm not sure where to look..,

ravenBlue’s picture

As stated in "Option 2" section, any call to DB has to be checked first by db_is_active() function, and in Zen themes I had some trouble because of this.
In the following link, zenic posted a simple fix, hope it helps.

xxparanormalxx’s picture


stickDeath’s picture

Used option 2 and worked just great!

bloke_zero’s picture

Not sure about replacing $content with you own message as then you'll loose the mysql error which can be pretty handy if e.g. you've gone over max connections - makes solving problems quicker to have the message which is stored in $content as a reference.

Vandalf’s picture

I got the maintenance-page.tpl.php to work just fine, but have problems with the maintenance-page-offline.tpl.php page.
This is what I did:

  • created a maintenance-page-offline.tpl.php page from my page.tpl.php file (copied and renamed it), and kept it in the root folder of my theme (sites/all/themes/danland/).
  • From before, my settings.php file had the
    $conf = array( 
    'maintenance_theme' => 'danland',

    defined (that is, I had already removed the hash (#) to create the maintenance-page.tpl.php page...)

  • cleared the cache
  • put the line db_url = 'x' at the bottom of my settings.php file.

What I now get when trying to enter my site is the following error message:

Fatal error: Call to undefined function db_result() in <...>/my_site/includes/ on line 54

Does anyone have a clue as to what I'm doing wrong? I tried to follow the steps in this post as well as I could, and also read through all comments to figure out what was really said in the post (wasn't the easiest to follow, as others have pointed out already, but still useful!). Any ideas appreciated!

sweethomeavocado’s picture

I can't get the maintenance-page--offline.tpl.php to use my theme. It keeps using garland (with no errors).

Here are the steps I took:

1. Set my theme (lake) to active in the theme administration page

2. Added to settings.php (the name of my theme .info file is and so is the theme folder, etc.:
$conf['maintenance_theme'] = 'lake';

3. Made a copy of my page.tpl.php template and renamed it to maintenance-page.tpl.php and created another called maintenance-page--offline.tpl.php in the root level of my lake theme directory.

4. Cleared the site cache

5. Modified my settings.php to force the db connection to break:
$db_url = '#';

It still shows the garland theme rather than my own. Is there something I'm missing?

kentr’s picture

I seem to recall recently having the same thing happen, and that adding a maintenance-page.tpl.php to the theme solved it.

drupalfan81’s picture

Thanks esharf! Your comment was work fixed it for me. It all had to do with the case of the letters. For some reason my theme has two uppercase letter and I entered as it appears in the .info file. After changing it to all lowercase, it worked. thank you!!

acbramley’s picture

Having a lot of issues getting this to work with memcache, I have set the following conf in settings.php:

$conf['maintenance_theme'] = 'my_theme';
$conf['blocked_ips'] = array();
$conf['page_cache_without_database'] = FALSE;
$conf['cache'] = FALSE;

But for some reason, if I break the db connection (doing this by simply changing the table name referenced in my $databases conf array, same behaviour if I just stop postgresql) I get this:

Additional uncaught exception thrown while handling exception.


PDOException: SQLSTATE[08006] [7] FATAL: database &quot;tpow-intranet2&quot; does not exist in _drupal_session_read() (line 102 of includes/


PDOException: SQLSTATE[08006] [7] FATAL: database &quot;tpow-intranet2&quot; does not exist in dblog_watchdog() (line 147 of modules/dblog/dblog.module).

Uncaught exception thrown in session handler.

PDOException: SQLSTATE[08006] [7] FATAL: database &quot;tpow-intranet2&quot; does not exist in db_merge() (line 2445 of includes/database/

If I then restart memcache I get my nicely presented maintenance-page--offline.tpl.php page.

I debugged this all the way down to _drupal_bootstrap_page_cache() hence why I added the extra $conf vars to attempt it to stop but it still includes the file etc. The reason I started adding those $conf entries was to mitigate the db_query on line 1916 of, I even followed the comment suggestions and still can't seem to get it working.

Has anyone got this working properly on D7 with memcache?

cdmo’s picture

I just experienced an issue where I couldn't get the offline template to appear and I tracked down the culprit in my settings.php:

$conf['preprocess_css'] = true;
$conf['preprocess_js'] = true;

Changed both to "false" and the template started working. I like setting these variables in the settings.php, but because of this problem I simply cannot. So, instead I turn the settings on for optimizing css and js through the GUI, which populates the database and lets Drupal's offline mode do it's thing. Hope this helps someone else arriving from Google.