How to Enable/Disable Maintenance Mode in Magento 2 via Command Line

Whenever you need to upload the new files or customize the code on the production server you should enable maintenance mode to take your store offline. In maintenance mode, your customers see a temporary page until you return to production mode. This blog will help you to enable/disable maintenance mode in Magento 2 via command line interface.

Check Maintenance Mode Status:

Run the below SSH command in your Magento 2 installed root directory to check whether the maintenance mode is enabled or disabled in your Magento 2 store.

php bin/magento maintenance:status

This will return the following output,

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

This shows that the maintenance mode is not enabled on your Magento 2 website.

Enable Maintenance Mode:

Run the below SSH command in your Magento 2 installed root directory to enable maintenance mode in your Magento 2 store.

php bin/magento maintenance:enable

This will return the following output,

Enabled maintenance mode

Enable Maintenance Mode for Specific IP Addresses:

Run the below SSH command in your Magento 2 installed root directory to enable maintenance mode for specific IP address,

php bin/magento maintenance:enable --ip=192.168.0.56 --ip=192.168.0.57

This will return the following output,

Enabled maintenance mode
Set exempt IP-addresses: 192.168.0.56, 192.168.0.57

The above command is used to enable maintenance mode and put two IP addresses (192.168.0.56 & 192.168.0.57) on the exclusion list. Which means all the users of the site will see the maintenance mode page but users accessing the website from IP address 192.168.0.56 & 192.168.0.57 will see the actual website page.

Remove IP Addresses From Exempt List:

Run the below SSH command to remove the IP address from the exempt list,

php bin/magento maintenance:enable --ip=none

This will return the following output,

Enabled maintenance mode
Set exempt IP-addresses: none

Disable Maintenance Mode:

Run the below SSH command in your Magento 2 installed root directory to disable maintenance mode in your Magento 2 store.

php bin/magento maintenance:disable

This will return the following output,

Disabled maintenance mode

Hope this helps.

Leave a Reply

Your email address will not be published. Required fields are marked *