Magento Tutorials

How to Enable/Disable Maintenance Mode in Magento 1 & 2

This guide is going to walk you through how to put your online store into Magento Maintenance Mode so that your customers would know your site is currently on-going. It includes instructions for both Magento 1 and Magento 2.

Put Magento 1 in Maintenance Mode

1. Enable

Step 1: Using SSH to log in to your account.

Step 2: Navigate to the file you get your Magento installed in.

Step 3: Open the index.php file with editor and enter the following lines with the following order after “ $maintenanceFile = ‘maintenance.flag’; “ :

$ip = $_SERVER['REMOTE_ADDR'];
$allowed = array('xxx.xxx.xxx.xxx');

Remember to replace “xxx.xxx.xxx.xxx” with the IP address that you would like to allow access to the front-end while your store is in Maintenance Mode. Also, you can add multiple IP address and separate them by comma “,”.

Step 4: Change: if (file_exists($maintenanceFile)) {

To: if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {

Step 5: Save all changes to the index.php

Step 6: Enter touch maintenance.flag into the SSH command prompt.

Now, all the authorized IPs is able to access the site normally. Other visitors will receive the following message:

magento maintenance mode page
Magento 1 Maintenance Mode

2. Disable

It is very simple to disable the Mode and re-enable your Magento online store.

You just need to enter the following command to SSH command prompt:

rm maintenance.flag

Put Magento 2 in Maintenance Mode

1. Enable

Step 1: Using SSH to log-in to your account.

Step 2: Navigate to the file you get your Magento installed in.

Step 3: Enter the following command to the SSH command prompt:

bin/magento maintenance:allow-ips xxx.xxx.xxx.xxx

Remember to replace “xxx.xxx.xxx.xxx” with the IP address that you would like to allow access to the front-end while your store is in Maintenance Mode.

Step 4: To enable the Mode, enter the following command:

bin/magento maintenance:enable

Now, all the authorized IPs is able to access the site normally. Other visitors will receive the following message:

magento maintenance mode backend
Magento 2 Maintenance Mode

2. Disable

It is very simple to disable the Mode and re-enable your Magento online store.

You just need to enter the following command to SSH command prompt:

bin/magento maintenance:disable

*Note: You can check your Maintenance Mode status by entering the following to the SSH command prompt:

bin/magento maintenance:status

Related posts:
Magento Admin Login Not Working Issue


SEE MORE:

Dom

A knowledge craver who always strive to be wiser everyday.