During theme or plugin upgrades, maintenance mode is enabled and then disabled once complete.

Is it possible to manually enable / disable maintenance mode?

Enabling Maintenance mode... Downloading update from xxxx Disabling Maintenance mode...


WP-CLI now has native commands for it.

# Activate Maintenance mode
$ wp maintenance-mode activate
# Deactivate Maintenance mode
$ wp maintenance-mode deactivate

See wp-cli/maintenance-mode-command for more information.


You can enable maintenance mode in WordPress by adding a .maintenance file to your root WordPress directory. It will need to include:

$upgrading = time();

With this file in place, your site will be in maintenance mode until you remove the file.

  • 4
    To add to that, WordPress looks at the timestamp of $upgrading and if it's more than 10 minutes old assumes the maintenance window has passed, and ignores the .maintenance file. – William Turrell Feb 10 '16 at 15:54
  • Which is not what OP asked for. They want to know how to do that using WP-CLI. – leymannx Apr 25 at 20:23
  • 1
    @leymannx There wasn't a way to enable / disable maintenance mode with WP-CLI at the time of my posting. – Daniel Bachhuber Apr 26 at 21:02

I use a plug-in for maintenance mode and always leave it "in" maintenance mode.

Practically you can then turn on/off the actual maintenance mode by turning on/off that plugi-in — which is easy through wp-cli:

# activate maintenance mode, flush caches and stuff
wp plugin activate ultimate-maintenance-mode
# do maintenance things
wp plugin deactivate ultimate-maintenance-mode
# flush caches again so the maintenance page does not show up
  • 1
    Great workaround! Although I can't believe there isn't a native feature in wp-cli that does that. – pagliuca Nov 19 '17 at 21:04
  • There doesn't seem to be a native WordPress function that does this, so wp-cli has nothing to call on. – Slam May 18 '18 at 22:07

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.