Fri. Apr 25th, 2025

3. Magento. How to put the website in maintenance mode

1 min read

This tutorial shows how to put Magento website in maintenance mode.

1. In order to put site to maintenance mode you should create empty maintenance.flag file and upload it to the root folder. After that your web site will look like on the screenshot.

Magento_how_to_put_the_website_in_maintenance_mode-1

2. Please note that even admin user can not access the site. In order to have access you should modify index.php file in Magento root folder and specify list of IPs that will have access to your site. Download and open original index.php file.

On line 47 put the following code:

$ip = $_SERVER[‘REMOTE_ADDR’];

$allowed = array(‘69.65.23.100′,’2.2.2.2’);

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.

3. Search the following code:

if (file_exists($maintenanceFile)) {

Replace it with

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

Look modified code you can see on the screenshot below.
Magento_how_to_put_the_website_in_maintenance_mode-2

4. Refresh your site. It should show up in case you put correct IP address.

Magento_how_to_put_the_website_in_maintenance_mode-3

5. In order to modify content of maintenance page you should edit errors/default/503.phtml file.
Magento_how_to_put_the_website_in_maintenance_mode-4

April 2025
M T W T F S S
« Jun    
 123456
78910111213
14151617181920
21222324252627
282930