Cannot Enable Magento 2 Maintenance Mode Excluding a Specific IP – How to Fix

magento2maintenance

I have a magento2 web application which I need to enable maintenance mode excluding a specific IP. The following command did enable the maintenance mode without excluding my IP.

php bin/magento maintenance:enable --ip=123.45.67.89

and I tried the following since the above command didn't work.

php bin/magento maintenance:allow-ips 123.45.67.89

var/.maintenance.ip does exist and it has my ip listed in it.

Best Answer

Are you by any chance using varnish or another reverse proxy? ie, it might be that your public IP does not get forwarded, and therefore cannot be recognised. Easiest check is the access logs on the webserver, see if you can see your own IP in there. Otherwise you'll have to implemented x-forwarded-for headers

Related Topic