How to Enable and Disable maintenance mode in Magento 2
Maintenance Mode is a useful to temporarily disable a website to test the site before it goes live, or do maintenance tasks such as updating, fixing the bug, etc.
When your website is in maintenance mode, store visitors will receive a Service Temporarily Unavailable message in their web browser instead of the frontend store.
Enable or Disable Maintenance Mode in Magento 2
Magento detects the maintenance mode as follows:
If the var/.maintenance.flag does not exist, the maintenance mode is off and the Magento website runs normally.
If var/.maintenance.flag exists, the maintenance mode is on.
Enable The Maintenance Mode in Magento 2
To enable Maintenance Mode in Magento 2 ,use the below command:
php bin/magento maintenance:enable [--ip=<ip address>] |
If you are looking to enable the maintenance mode for any particular IP, pass the IP in the above-mentioned command.
For example
php bin/magento maintenance:enable --ip=192.168.1.10 |
By using the above command, you will enable the maintenance mode for IP address 192.168.1.10.
Disable The Maintenance Mode in Magento 2
To Disable Maintenance Mode in Magento 2 ,use the below command:
php bin/magento maintenance:disable [--ip=<ip address>] |
If you are looking to disable the maintenance mode for any particular IP, pass the IP in the above-mentioned command.
Magento 2 maintenance mode page
Steps to Custom Maintenance mode Page in Magento 2:
Step 1: Go to the pub/error folder then rename local.xml.sample to local.xml file:
<?xml version="1.0"?> <config><skin>hello</skin> <report><action>print</action><subject>Store Debug Information</subject><email_address></email_address><trash>leave</trash></report></config> |
Step 2: Now copy the default folder and rename it. Give name hello because we add this name on skin tag in local.xml
Step 3: Now go to hello folder and open 503.phtml and add your custom code and design to show custom maintenance page.
<?php/*** Copyright © Magento, Inc. All rights reserved.* See COPYING.txt for license details.*/?> <h1>Service Temporarily Unavailable</h1> <p class="text-base text-clr mb-4"> The server is temporarily unable to service your request due to maintenance downtime or capacity problems.Please try again later. </p> |
Step 4: Refresh the page.
Magento 2 maintenance modes allow IP not working
Use the following command to allow access to the frontend store from a specific IP address while Magento website is in maintenance mode:
php bin/magento maintenance:allow-ips <ip address> .. <ip address> [--none] |
Conclusion:
We hope the above blog is helpful to understand how to Enable and Disable maintenance mode in Magento 2.
You can also use our Magento 2 Maintenance Mode extension to design your own custom maintenance page for your online store and update your visitors about your website maintenance status.
If you have any query then you contact us or let us know in the comment section.