Did you ever come across a temporary caution board on a website mentioning Work in Progress?
These are the ones that are used to notify people about the state of the website. Now, what if you are looking for something like that in your Magento 2 store?
It is an easy task on the Magento 2 store with the help of maintenance mode.
What is Maintenance Mode?
Maintenance Mode is a shortcut that can be used to serve a temporary error notification to all the visitors from your store and ask them to visit later. The maintenance mode is helpful when you are setting up a new theme, during the configuration of an extension, upgrading to the latest Magento 2 version, implementing customizations, fixing a security flaw.
Enabling the maintenance mode shows users broken websites for a while. When Magento is in maintenance mode, visitors see maintenance-enabled notification messages on their web browsers in place of the store.
Authorized IP Addresses can still view the store normally.
As shown below, an error message is displayed:
Now, here are methods to enable or disable maintenance mode in Magento 2.
Enable the Maintenance Mode
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. Using this, you can enable the maintenance mode for two IP addresses. The IP address of the developer who plans to debug your website is probably included in the above command.
Otherwise, pass the below command:
php bin/magento maintenance:enable
Disable the Maintenance Mode
For particular IP:
php bin/magento maintenance:disable [--ip=<ip address>]
To disable the mode overall:
php bin/magento maintenance:disable
Show Maintenance Status
Use the below command to know the current status of the maintenance mode:
php bin/magento maintenance:status
Exempt IP Addresses from Maintenance Mode
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 1> .. <ip address 5> [--none]
There you go!
Here is the quickest possible way to enable and disable maintenance mode on your Magento 2 store. If you face any issue while doing so, feel free to reach us out.
Recommended: How to Enable / Disable Developer Mode in Magento 2?