This article describes how to enable maintenance mode in Magento. When Magento is in maintenance mode, visitors see a Service Temporarily Unavailable message in their web browsers instead of the store. However, authorized IP addresses can still view the store normally.
This feature allows you to develop and test your store before it goes "live," or do other maintenance tasks, such as installing updates.
To enable maintenance mode in Magento 2, follow these steps:
cd ~/public_html
To permit access to the front-end store from a specific IP address while Magento is in maintenance mode, type the following command. Replace xxx.xxx.xxx.xxx with the IP address for which you want to allow access:
bin/magento maintenance:allow-ips xxx.xxx.xxx.xxx
To enable maintenance mode, type the following command:
bin/magento maintenance:enable
Maintenance mode is now enabled. When you visit Magento from an authorized IP address, the store displays normally. All other site visitors, however, receive a Service Temporarily Unavailable message in their web browsers.
To disable maintenance mode and re-enable the store for all visitors, type the following command:
bin/magento maintenance:disable
To view the maintenance mode status at any time, type the following command:
bin/magento maintenance:status
To enable maintenance mode in Magento 1.9 and older versions, follow these steps:
$maintenanceFile = 'maintenance.flag';
After this line, add the following two lines. Replace xxx.xxx.xxx.xxx with the IP address for which you want to permit access to the front-end store while Magento is in maintenance mode:
$ip = $_SERVER['REMOTE_ADDR'];
$allowed = array('xxx.xxx.xxx.xxx');
$allowed = array('10.1.0.127', '10.1.0.252');
Locate the following line in the index.php file:
if (file_exists($maintenanceFile)) {
Change the line to look like the following:
if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {
At the command prompt, type the following command:
touch maintenance.flag
Maintenance mode is now enabled. When you visit Magento from an authorized IP address, the store displays normally. All other site visitors, however, receive a Service Temporarily Unavailable message in their web browsers.
To disable maintenance mode and re-enable the store for all visitors, type the following command:
rm maintenance.flag