Magento 2 – maintenance mode
In this tutorial I show you how to use Magento 2 maintenance mode. This is useful, especially if you deploy updates on your production system. If you run a static content redeploy on multi language stores you may discover display problems and errors during deployment. You do not want customers discover weird things on your website.
Magento 2 – maintenance mode
If you activate Magento 2 maintenance mode, a maintenance site will be shown. You can activate it with:
1 | php bim/magento maintenance:enable |
During active maintenance mode you can do all things you want, no one will see your changes. After your work is done you will deactivate it with:
1 | php bin/magento maintenance:disable |
If you have a automatic deployment script for your shop source code it makes sense to use this maintenance mode for production systems. For our deployment script this is very useful. Normally it is obvious if this mode is on or off, but there is also an option to check the current status.
Customization
Magento 2 has a very ugly maintenance site. It looks like this:
It is highly recommended to design your own site for each shop based on its design. A good looking “service temporarily unavailable” site with information helps not to loose potential customers. For this you only need to edit Magento 2 503 site:
1 | pub/errors/default/503.phtml |
If you develop more than one Magento 2 shop, you can use a template design, which can be customized for each shop.
IP addresses
It is possible, that you exclude IP addresses from maintenance site. This is needed if you want to check if everything looks good before disabling maintenance mode. It is also useful if you are working on things in Magento backend during deployment. You can exclude addresses with the following command (you can exclude as many addresses as you want):
1 | php bin/magento maintenance:enable --ip=80.120.40.17 --ip=80.123.40.18 |
So you and shop owner can check things whereas all other users can not see the shop frontend.
Conclusion
Magento 2 uses a maintenance mode to show a maintenance page to customers. This is very useful for automated deployment scripts. You can exclude IP addresses from this.
Briefly explained article! It helped me a lot in understanding the basics and advanced levels of maintenance mode. Thanks a lot.
thank you for your comment. Always good to know if my articles are helpful.
Is it possible to do this without SSH, with uploading the files directly to the folder via FTP?
Yes, you can upload an empty .maintenance.flag file to var/.maintenance.flag. If that file doesn’t exist, Magento runs with maintenance off.