10

Does anyone know how to turn off maintenance mode? I tried accessing http://www.example.com/?q=user/login, but that gives me a blank page. I tried executing this SQL query, but it didn't affect any record.

UPDATE `variable` SET `value`='0' WHERE 'name' = 'maintenance_mode';

I tried to find a $conf['maintenance_mode'] variable in the project, but it doesn't exist. Adding $conf['maintenance_mode'] = false; in the setting.php file didn't do anything either.

How do I turn off maintenance mode?

1
  • I had the same issue. Every solution reported in the answers for this question didn't work. I solved it by running cron tasks.
    – roeland
    Commented Nov 3, 2015 at 12:51

7 Answers 7

27

Using Drush, you can run drush vset maintenance_mode 0 to disable the maintenance mode on a Drupal 7 site.

0
15

The answer by schnippy is correct; however, some details are wrong, at least in Drupal 7.28.

The query to change maintenance_mode should be:

UPDATE variable SET value = 'i:0;' WHERE name= 'maintenance_mode';

The value is an integer, even if a string might work as well. It's just not what Drupal itself uses.

More importantly, in order to reset the cache for maintenance_mode, the table to use is cache_bootstrap.

DELETE FROM cache_bootstrap WHERE cid = 'variables';

There is no cache with ID equal to variables, inside the cache table.

This is tested and works with Drupal 7.28.

1
  • 1
    This is correct. Although the serialized string will also generally work because this value is usually checked using the equals operator instead of the identical one this way is safer.
    – rooby
    Commented Nov 17, 2014 at 5:26
7

You're on the right track with the database approach but your query is wrong since the variables are serialized. The actual syntax is:

UPDATE variable SET value = 's:1:"0";' WHERE name= 'maintenance_mode';

Also - its a good idea to follow this by flushing the variables cache:

DELETE FROM cache WHERE cid = 'variables';
1
  • 1
    +1 for the suggestion of flushing the cache, since the values of persistent variables are cached.
    – avpaderno
    Commented Jan 22, 2014 at 21:36
5

Maintenance mode is triggered by the variable "maintenance_mode", which is set to 1 when activated.

This is the code present in the System module (system.admin.inc, line 2194).

/**
 * Form builder; Configure the site's maintenance status.
 *
 * @ingroup forms
 * @see system_settings_form()
 */
function system_site_maintenance_mode() {
  $form['maintenance_mode'] = array(
    '#type' => 'checkbox',
    '#title' => t('Put site into maintenance mode'),
    '#default_value' => variable_get('maintenance_mode', 0),
    '#description' => t('When enabled, only users with the "Use the site in maintenance mode" <a href="@permissions-url">permission</a> are able to access your site to perform maintenance; all other visitors see the maintenance mode message configured below. Authorized users can log in directly via the <a href="@user-login">user login</a> page.', array('@permissions-url' => url('admin/people/permissions'), '@user-login' => url('user'))),
  );
  $form['maintenance_mode_message'] = array(
    '#type' => 'textarea',
    '#title' => t('Maintenance mode message'),
    '#default_value' => variable_get('maintenance_mode_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))),
    '#description' => t('Message to show visitors when the site is in maintenance mode.')
  );

  return system_settings_form($form);
}

You can use drush to disable maintenance mode.

drush vset maintenance_mode 0;
drush cc all;

You can also use variable_set('maintenance_mode', 0) and clear cache afterwards (with a call to cache_clear_all()).

1
  • 1
    Drush for everything :) I'm glad you added the drush command to do it. Commented Jan 23, 2014 at 2:47
2

With the latest version of Drush/Drupal the command has changed:

drush state:set system.maintenance_mode 0 --input-format=integer
drush cache:rebuild

Drupal documentation

0

If you remember your username and password, login from http://www.example.com/?q=user. Then go to Configuration >> Maintenance mode; uncheck Put site into maintenance mode, and save.

-3

In my case, Drush was not working and I could bring back the site by doing this:

Add the below line in docroot\core\lib\Drupal\Core\EventSubscriber\MaintenanceModeSubscriber.php

\Drupal::state()->set('system.maintenance_mode', FALSE);

Run the site again for 2-3 times (clearing the cache) and it is up again.

Remember to take out this line once your site is up

1
  • 1
    Please don't do this
    – baikho
    Commented Mar 23, 2021 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.