Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  CMS FAQ  >  Learn to Enable and Disable Magento Maintenance Mode
Top Scroll

Learn to Enable and Disable Magento Maintenance Mode

 3 min

Maintenance mode is not only an important but useful mode in Magento. This mode is enabled in case you want to disable your website temporarily prior to making it live or performing maintenance tasks such as bug fixing, updating, etc. When your website is in maintenance mode, store visitors receive a Service Temporarily Unavailable message in their web browser rather than the frontend store. But you can access it from authorized IP addresses for checking the store normally.

Steps to Enable and Disable Maintenance Mode in Magento 1

1. Login to your Magento administrator account using SSH.

2. Switch to the directory where Magento is installed. For instance, if you installed Magento in the document root directory, type the below command:

cd ~/public_html

3. Using your preferred text editor, open the index.php file.

4. Paste the below line in the index.php file:

$maintenanceFile = 'maintenance.flag';

5. Add the below two lines after this. Where is the IP address for which you want to enable the access to the front-end store while Magento is in maintenance mode.

$allowed = array('');

Note: To discover multiple IP addresses from the maintenance model, separate them with a comma.

For example:

$allowed = array('','');

6. For knowing your own IP address, access the website:

7. Add the below line in the index.php file:

if (file_exists($maintenanceFile)) {

8. Change the line in the following way:

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

9. Save your changes to the index.php file and close the editor.

10.On the command prompt enter the below command:

touch maintenance.flag

Once you complete with the above steps, your status is set to maintenance mode. After accessing the Magento website from an authorized IP address, the store will display normally. But when your visitors browse the website, they will get a Service Temporarily Unavailable message displayed.

For disabling the maintenance mode and allowing the access of the frontend store to all visitors, type the following command:

rm maintenance.flag

Steps to Enable or Disable Maintenance Mode in Magento 2

Magento detects the maintenance mode in the below way:

  • If var/.maintenance.flag is not available, the maintenance mode is off and Magento website runs normally.
  • If var/.maintenance.flag is present, the maintenance mode is on.

But, the maintenance status is also based on the file var/.maintenance.ip. There will some exceptions made by this file to turn off the Magento 2 maintenance mode even if var/.maintenance.flag is present.

1. Login to your account using SSH.

2. Go to the file where your Magento is installed in.

3. Add the below command to the command prompt of SSH:

php bin/magento maintenance:enable [--ip=<ip address>]

For example

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

4. With the use of the above command, you will enable the maintenance mode for two IP addresses and The developer’s IP address who wants to debug your website is usually included in the above command.

5. To disable the maintenance mode use the below command:

php bin/magento maintenance:disable [--ip=<ip address>]

6. To check the current status of the maintenance mode, use the below command:

php bin/magento maintenance:status

Steps to Exempt IP Addresses From Maintainance Mode

For enabling the access to the frontend store from a specific IP address when you put Magento website in maintenance mode, type the below command:

php bin/magento maintenance:allow-ips <ip address> .. <ip address> [--none]

For example:

php bin/magento maintenance:allow-ips


The above are the short and simple processes to enable/disable maintenance mode in Magento 2. This guide will help you to manage the maintenance mode in Magento easily.

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
Claim the discount before it’s too late. Use the coupon code:
Note: Copy the coupon code and apply it on checkout.