Is it possible to take a Drupal site offline using Drush?
6 Answers
Yep. drush vset site_offline 1
will set it offline, then drush vdel site_offline
will bring it back.
Alternatively, you can check out my Maintenance File module on drupal.org, which will set your site to offline if it finds a specific file in the directory.

- 3,254
- 20
- 19
Just in case anyone needs to do this with Drupal 7, the commands are:
drush vset maintenance_mode 1 --yes # Take site offline
drush vset maintenance_mode 0 --yes # Put site back online
It also helps to add a little drush cc all
after each of those commands to ensure that the change appears instantaneous to users.

- 3,264
- 2
- 24
- 30
-
This syntax also works with drupal 6 on current drush, so is probably preferred. – ErichBSchulz Nov 17 '12 at 02:20
theunraveler's solution is the best if you're running a single site. We were running a very large multisite drupal installation, with hundreds of sites. Taking them offline that way via drush takes several seconds per site which was unacceptable. The fastest way to take a site offline is to break the db connection by for example renaming the settings.php file. Then just assign a default theme that has a basic template that doesn't require the db, saying "Site Offline" or something. After upgrading you can just repair the settings.php file and you're good to go.

- 5,493
- 4
- 33
- 31
-
That takes just as long. To set a default theme for each site, you have to make a database change. The drush command above is also making a change in the database: it is the same as UPDATE {variables} SET value = 1 WHERE name = 'site_offline'. So, the issue is not with drush or even this method of setting sites offline, which is obviously the most ideal. – theunraveler Oct 28 '10 at 19:49
-
@theunraveler: I think the point is that you only need to make a single change once you have done the setup. Not a method I would use myself though. – googletorp Oct 28 '10 at 20:23
-
@theunraveler: that's not the case. in a multisite setup you can set a default theme in the base installation so that if you can't reach one of the "multisite" sites it defaults to that base theme. trust me i spent a lot of time investigating this including making the db change directly. that's not sufficient because the cache doesn't get flushed. as i mentioned above, i don't recommend this unless you have a lot of sites and performance is important. but with this technique you can take 500 sites offline in a couple seconds, versus 5-7 seconds per site via drush – Nader Oct 28 '10 at 20:32
-
Ah! I didn't know Drupal would fall back to a default theme if it couldn't find the actual theme. Although I still think that the Maintenance File module would be a better option. Good to know, though! +1 – theunraveler Oct 28 '10 at 21:03
With a site alias on D7:
drush @site_alias -y vset maintenance_mode 1 # Take site offline
drush @site_alias -y vset maintenance_mode 0 # Take site online

- 6,980
- 1
- 38
- 48
It's quite easy in fact, simply set the variable of maintenance mode to 1 (0 to restore default value):
drush vset maintenance_mode 1

- 29,806
- 6
- 60
- 99