Home » Magento, Magento 227 November 2017

Magento 2: Maintenance mode via Command Line

This article shows how you can enable or disable Maintenance mode in Magento 2 using the command line. In my previous article, I have listed out all the command line tools that can be used in Magento 2. This article specifically shows about commands to enable/disable maintenance mode in Magento 2.

Check Maintenance Mode Status

First of all, let’s get the information of the maintenance mode in Magento 2. We check whether the maintenance mode is enabled or disabled.

Running the above command will output something like this:

Status: maintenance mode is not active
List of exempt IP-addresses: none

This shows that the maintenance mode is not enabled on the Magento site.

Enable Maintenance Mode

You can enable maintenance mode with the following command:

Running the above command will output something like this:

Enabled maintenance mode

Now, let’s again check the status of the maintenance mode:

Running the above command will output something like this:

Status: maintenance mode is active
List of exempt IP-addresses: none

Enable Maintenance Mode for Specific IP Addresses

Above way of enabling maintenance mode will activate the maintenance mode for all IP addresses. No one will be able to access the frontend of the site.

But, you might have the requirement to allow the Magento site’s frontend access to particular people. For example, you might need to give access to the site to the website developer.

In such scenario, you have to set the IP address of the developer in the allowed list. That is, anyone from the allowed IP address can access the site even in the maintenance mode.

Let us enable maintenance mode and put two IP addresses (192.168.0.107 & 192.168.0.108) on the exclusion list. That means all users of the site will see the Maintenance mode page but users accessing the site from IP address 192.168.0.107 & 192.168.0.108 will see the actual site page.

Running the above command will output something like this:

Enabled maintenance mode
Set exempt IP-addresses: 192.168.0.107, 192.168.0.108

Check Status

Running the above command will output something like this:

Status: maintenance mode is active
List of exempt IP-addresses: 192.168.0.107, 192.168.0.108

To remove all IP addresses from the exempt list

Running the above command will output something like this:

Enabled maintenance mode
Set exempt IP-addresses: none

Disable Maintenance Mode

You can disable maintenance mode with the following command:

Running the above command will output something like this:

Disabled maintenance mode

Hope this helps. Thanks.

Magento 2

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed