Enabling Maintenance Mode in Drupal with Drush
Depending on your Drupal version, you can enable maintenance mode with Drush as follows:
For Drupal 8 and Later
Enable Maintenance Mode:
drush sset system.maintenance_mode 1
Rebuild Caches:
drush cr
This sets the system.maintenance_mode
state variable to 1
(true) and then clears the caches so that the change takes effect.
For Drupal 7
Enable Maintenance Mode:
drush vset maintenance_mode 1
Clear All Caches:
drush cc all
Here, drush vset
sets the maintenance_mode
variable to 1
(true), and drush cc all
clears all caches.
Disabling Maintenance Mode
When you're ready to bring your site back online, simply reverse the commands:
Drupal 8 / 9 / 10 / 11:
drush sset system.maintenance_mode 0
drush cr
Drupal 7:
drush vset maintenance_mode 0
drush cc all
Using these Drush commands will put your site into maintenance mode (which displays your configured maintenance page) or take it out of maintenance mode as needed.