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=

where –ip= 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=

For more information go to :

Leave a Reply

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