How to put Magento 2 in maintenance mode

Even I think this should be a simple checkbox in Magento Control Panel but the most simple way I found is to put a file in var folder with the name of: var/.maintenance.flag

If you want to allow an ip or a group of ips you simply write this list of ips in a file: var/.maintenance.ip

Of course if you have access to CLI you can just type:

bin/magento maintenance:enable –ip=1.2.3.4

where –ip=1.2.3.4 is the ip that can access the website normally ..

if you use a shared hosting, to run the above command you have to go to the public_html folder first :
cd public_html

and then run the command using php
php bin/magento maintenance:enable –ip=1.2.3.4

For more information go to :
https://devdocs.magento.com/guides/v2.3/install-gde/install/cli/install-cli-subcommands-maint.html

Leave a Reply

Your email address will not be published. Required fields are marked *