EveryHost logo with 'EveryHost' text and whirlwind graphic symbolising speed

Secure.
Innovative.
Transparent.

How to Place Magento 1 and 2 in Maintenance Mode Print

  • magento, maintenance mode magento 2, maintenance mode magento 1, maintenance.flag
  • 29

A handy feature when working on or migrating a Magento site is the ease in which you can prevent customers accessing your store from URL other than your home page.

This will prevent duplicate orders in times such as migration to a new host. Details for each Magento version are as follows:

Magento 1 Enable

To put a Magento site in maintenance mode, you need to create an empty maintenance.flag file and upload it to the root folder of your site. After that your web site will look like this:

Note, that once you enable the maintenance mode, even if logged as admin, you won't be able to access the front end of the site. You will need to modify the index.php file in the Magento root folder to grant access to certain IP addresses that can load the site. To do this, open the index.php file and add this code on line 49:

 

 

 

 

In the $allowed = array(‘69.65.23.100′,’2.2.2.2′); you should specify list of IPs that will have access to your site.

Next, search for this piece of code:

 

 

 

and replace it with this:

 

 

 

The modified index.php file should look like this:

 

 

 

 

 

 

 

 

 

 

If you want to display more information than simply a maintenance mode text, you can edit the 503.phtml file located under the Errors/Default folder.

Magento 1 Disable

Delete file maintenance.flag under public_html

Magento 2 Enable Maintenance Mode

Using SSH to log-in to your account.

Navigate to the file you get your Magento installed in.

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.

To enable maintenance mode, enter the following command:

bin/magento maintenance:enable

 

Magento 2 Disable Maintenance Mode

bin/magento maintenance:disable

 


Was this answer helpful?

« Back