How can I take a site offline using Drush?

5 Answers 5


Drupal 8: drush sset system.maintenance_mode TRUE

Drupal 7: drush vset maintenance_mode 1

Drupal 6: drush vset site_offline 1

  • 7
    If you are using drush-5.x, you may now simply use "drush vset maintenance_mode 1". Drush will rewrite maintenance_mode to site_offline for Drupal 6. (This feature is newer than the above answer.) Dec 7, 2011 at 18:28
  • 7
    Be sure to clear caches (drush cc all) after changing this variable.
    – smokris
    Mar 3, 2012 at 0:53
  • 2
    Drupal 8: drush state-set system.maintenance_mode 1 (I don't like drush's aliases)
    – Andrea
    Apr 29, 2016 at 14:23
  • Drupal 8 should also be 1 or 0 - not true or false. drush sset system.maintenance_mode 1
    – NicklasF
    Jan 5 at 13:51

First you should cd into the correct directory so that you are within the Drupal directory. If you are using a multi site installation cd into the correct sites/sitename directory or specify the correct -l setting

In Drupal 6 only this command is actually required:

$ drush vset --yes site_offline 1;

Also in Drupal 6 you can use the following commands if you wish to specify a message to show to the users of the site whilst it is down.

$ drush vset --yes site_offline_message "This site is being maintained";
$ drush vset --yes site_offline 1;

In Drupal 7 use following command to put the site into maintenance mode:

$ drush vset --yes maintenance_mode 1;

To set an a specific message use:

$ drush variable-set --yes maintenance_mode_message "This site is being maintained"

It could be necessary to clear caches that the changes of these variables take effect:

$ drush cc all
  • 1
    This does not work if the variable does not already exist. You're missing the --always-set parameter. Mar 2, 2011 at 21:10
  • 1
    The variable gets created by the installer though. Go install a fresh drupal and look in the variable table. Mar 2, 2011 at 21:23
  • 1
    Upvoted due to including the site_offline_message part. I believe the Drupal 7 equivalent of site_offline_message is maintenance_mode_message?
    – lolcode
    Mar 27, 2013 at 13:32
  • You don't need to clear the cache, variable_set() does that for you: api.drupal.org/api/drupal/includes%21bootstrap.inc/function/…
    – mvc
    Jun 1, 2016 at 12:30
  • 1
    variable_set only clears two caches. cache_clear_all('variables', 'cache_bootstrap'); Jul 12, 2016 at 13:15

To do this with Drupal 8 and Drush 8.x use the state-set command:

drush sset system.maintenance_mode 1

At first, I assumed this would be something I would set with drush config-set system.maintenance, however the only keys in that configuration are message (the message displayed when maintenance mode is enabled) and langcode (the language code for said message).


This is controlled by a variable, site_offline.

$ drush vset --always-set site_offline 1

You could also set the offline message this way.

$ drush vset --always-set site_offline_message 'Please try again later!'
  • This would bring the site back up if it is down for maintenance. Mar 2, 2011 at 21:05
  • Thanks for pointing that out. Of course it should be set to 1, nothing else. Mar 2, 2011 at 21:08

From Drupal 6 use:

drush vset site_offline 1

To take it out of maintenance:

drush vset site_offline 0
drush cc all

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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