Magento 2 Maintenance

As a store owner you will require at some point to block temporary access for Customers for maintaining, upgrading or reconfiguring the store.

As a store owner you will require at some point to block temporary access for Customers for maintaining, upgrading or reconfiguring the store. Magento offers a maintenance mode to disable access to the site while you do these.

It looks for a flag in the filesystem at a specific path var/.maintenance.flag. If the file is not present then Magento doesn’t enter Maintenance Mode, if it is then access is denied to Customers unless they are in the Allowed Ips list.

Maintenance Mode Enable #

To enable maintenance mode in Magento you can run the following command:

bin/magento maintenance:enable

Result will show:

Enabled maintenance mode

The command basically creates the file var/.maintenance.flag.

Maintenance Allow IP’s #

To allow certain IP’s to bypass Maintenance mode you can use the command bellow:

bin/magento maintenance:allow-ips 1.1.1.1

where 1.1.1.1 is the IP allowed to bypass. And the mode will be show as:

Set exempt IP-addresses: 1.1.1.1

To add a allowed IP to a already existing list of IPs you can use the --add argument as bellow:

bin/magento maintenance:allow-ips --add 2.2.2.2

Result will be a list of all the previouse set IPs with the new addition last:

Set exempt IP-addresses: 1.1.1.1 2.2.2.2

All the IP’s added with this can also be reviewed via path var/.maintenance.ip

Maintenance Allow IP’s Clear #

To clear the list of allowed IP’s you can run:

bin/magento maintenance:allow-ips --none

And the result will show:

Set exempt IP-addresses: none

Maintenance Status #

To view the current status of maintenance mode, this will also show you any allowed-ips you might have set, use command:

bin/magento maintenance:status

This will output the current maintenance mode, if not active:

Status: maintenance mode is not active
List of exempt IP-addr esses: 1.1.1.1

or if it is active:

Status: maintenance mode is active
List of exempt IP-addresses: 1.1.1.1

Mainteneance Mode Disable #

To disabled maintenance mode in Magento you can run the following command:

bin/magento maintenance:disable

Result will show:

Disabled maintenance mode

Need help with Magento 2 Maintenance ?