Table of contents
Get the industry’s fastest hosting for WordPress◦ 99.999% uptime
◦ Comprehensive security
◦ 24/7 support

WordPress GuideWP-CLI → Maintenance Mode

Set WordPress maintenance mode using WP-CLI

Enable maintenance mode on your site during scheduled maintenance and for other valid reasons using the WordPress Command Line Interface (WP-CLI) with ease.

Get fast, reliable hosting for WordPress

Power your site with the industry’s fastest, most optimized WordPress hosting

How to enable & disable maintenance mode in WordPress using WP-CLI

Why enable maintenance mode

When you have extensive content updates, plugin updates, or changing out plugins on your WordPress site, it is worth putting your site into maintenance mode so that you can make those changes without users trying to access the site. By turning on maintenance mode, when site visitors go to access the site, then they are met with a message letting them know that site is being worked on. 

This well communicated maintenance status for the site will allow you to be able to make the manual site changes or to administer a version control workflow push of planned changes if you are importing in content. In summary, making major changes on a site are best performed in a maintenance mode to avoid users encountering an error or other unexpected behaviors.

One logical use case of when maintenance mode should be enabled would be if you planned on changing a theme on the site. Instead of having the site be public while you installed and activated a new theme, maintenance mode should be turned on. Another logical user use care would be for the importing in the new customizer settings, which would lead to site visitors accessing the site in an incomplete and less than finished status if maintenance mode had not been turned on. 

Another good reason why you would want to put your production site into maintenance mode would be if you are pushing changes from your staging or development site, and you can keep the maintenance mode enabled during that process. If you are on a non-cloud server, you could manually create a dev site to be able to make changes before those changes are pushed manually or using a version control workflow to the production site.

WordPress enables maintenance mode using .maintenance file that would be created in the site’s public HTML folder on the site’s server. Maintenance mode would automatically be enabled when you update plugins or themes from within wp-admin.

With maintenance mode enabled on your site, when you or a site visitor goes to access the site URL, the browser will display the following message:

Briefly unavailable for scheduled maintenance. Check back in a minute.

How to use WP-CLI

To be able to use WP-CLI on your site, you will need to have logged into the Liquid Web Portal to find and get the SSH credentials for the site’s server. It is recommended to use a command-line application to use WP-CLI. For example, a macOS device would already have the Terminal application installed, and on a Windows or Linux device, you can install the PuTTY application.

Valid folder for WP-CLI

To use WP-CLI on your site’s server, you will need to be in the correct folder of your WordPress installation. If you are not in the proper WordPress installation folder, then WP-CLI will not work. The command to change the directory to the WordPress installation would be:

cd public

Activate maintenance mode

To activate maintenance mode on your site, the WP-CLI command to run is:

wp maintenance-mode activate

You can also add the force flag to force activate the maintenance mode using this WP-CLI command:

wp maintenance-mode activate –force

Deactivate maintenance mode

When you have finished making changes on your site, then you can then deactivate the maintenance mode. You can do so by running the following command:

wp maintenance-mode deactivate

Is maintenance mode active

If you quickly need to check if maintenance mode is active or not on your site, you can run the following command:

wp maintenance-mode is-active

Checking maintenance mode status

To be able to check the status of maintenance mode on the site, you can run the following command:

wp maintenance-mode status

This will show if maintenance mode is activated or deactivated.

Why maintenance mode is useful

First of all, being able to easily enable maintenance mode without having to install and activate a plugin to do so is a time saver. And being able to enable, deactivate, and check the status all from the command line using WP-CLI is very useful. Doing so allows you to be able to safely make updates on the site or push content changes without having site users deal with a site that is in the process of being updated. Therefore, the WP-CLI command is an essential part of a clear developer workflow. 

Additional resources

What is WordPress? →

A complete beginner’s guide—from use cases, to basics, to how to get started

Installing WordPress using WP-CLI →

With your SSH credentials, learn how to install WordPress using the WordPress Command Line Interface (WP-CLI) after creating a database for the new WordPress install.

How to integrate WordPress and Slack →

If your org uses Slack and WordPress, there are several ways you can tie them together.

Luke Cavanagh

Luke Cavanagh, Strategic Support & Accelerant at Liquid Web, is one of the company’s most seasoned subject matter experts, focusing on web hosting, digital marketing, and ecommerce. He is dedicated to educating readers on the latest trends and advancements in technology and digital infrastructure.