Enable or disable maintenance mode

Magento uses maintenance mode to disable bootstrapping; for example, while you’re maintaining, upgrading, or reconfiguring your site.

Magento detects maintenance mode as follows:

  • If var/.maintenance.flag does not exist, maintenance mode is off and Magento operates normally.
  • Otherwise, maintenance mode is on unless var/.maintenance.ip exists:

    var/.maintenance.ip can contain a list of IP addresses. If an entry point is accessed using HTTP and the client IP address corresponds to one of the entries in that list, then maintenance mode is off.

First steps

  1. Log in to the Magento server as, or switch to, a user with permissions to write to the Magento file system. See switch to the Magento file system owner.

    If you use the bash shell, you can use the following syntax to switch to the Magento file system owner and enter the command at the same time:

    su <Magento file system owner> -s /bin/bash -c <command>

    If the Magento file system owner does not allow logins, you can do the following:

    sudo -u <Magento file system owner>  <command>
  2. To run Magento commands from any directory, add <magento_root>/bin to your system PATH.

    Because shells have differing syntax, consult a reference like unix.stackexchange.com.

    Sample bash shell for CentOS:

    export PATH=$PATH:/var/www/html/magento2/bin

    Optionally, you can run the commands in the following ways:

    • cd <magento_root>/bin and run them as ./magento <command name>
    • <magento_root>/bin/magento <command name>
    • <magento_root> is a subdirectory of your web server docroot. Need help locating the docroot?

In addition to the command arguments discussed here, see Common arguments.


Before you use this command, you must install the Magento software.

Enable or disable maintenance mode

Use the magento maintenance CLI command to enable or disable Magento maintenance mode.

Command usage:

magento maintenance:enable [--ip=<ip address> ... --ip=<ip address>] | [ip=none]
magento maintenance:disable [--ip=<ip address> ... --ip=<ip address>] | [ip=none]
magento maintenance:status


--ip=<ip address> is an IP address to exempt from maintenance mode (for example, developers doing the maintenance). To exempt more than one IP address in the same command, use the option multiple times.

Using --ip=<ip address> with magento maintenance:disable means only that you’re saving the list of IPs for later use. To clear the list of exempt IPs, you can use magento maintenance:enable --ip=none or see Maintain the list of exempt IP addresses.

magento maintenance:status displays the current status of maintenance mode.

For example, to enable maintenance mode with no IP address exemptions:

magento maintenance:enable

To enable maintenance mode for all clients except and

magento maintenance:enable --ip= --ip=

After you place Magento in maintenance mode, you must stop all message queue consumer processes. One way to find these processes is to run the ps -ef | grep queue:consumers:start command. Then run the kill <process_id> command for each consumer. In a multiple node environment, be sure to repeat this task on each node.

Maintain the list of exempt IP addresses

To maintain the list of exempt IP addresses, you can either use the [--ip=<ip list>] option in the preceding commands or you can use the following:

magento maintenance:allow-ips <ip address> .. <ip address> [--none]


<ip address> .. <ip address> is an optional space-delimited list of IP addresses to exempt.

--none clears the list.

Related topics