> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Enabling Magento maintenance mode

> Magento's maintenance mode lets authorized IPs access the store, while others see a maintenance message, ideal for development, testing, or updates.

This article describes how to enable maintenance mode in Magento. When Magento is in maintenance mode, visitors see a **Service Temporarily Unavailable** message in their web browsers instead of the store. However, authorized IP addresses can still view the store normally.

This feature allows you to develop and test your store before it goes "live," or do other maintenance tasks, such as installing updates.

## Enabling maintenance mode in Magento 2

To enable maintenance mode in Magento 2, follow these steps:

1. If you have not already done so, enable the Magento command-line interface (CLI). For information about how to do this, please see [this article](/docs/using-the-magento-command-line-interface-cli).

2. Log in to your account [using SSH](/docs/using-ssh-secure-shell).

3. At the command prompt, type the following command:

```bash theme={null}
cd ~/public_html
```

<Note>
  If you installed Magento 2 in a subdirectory, change to that directory instead. For example, if you installed Magento in a subdirectory named *mag2*, you would type\
  **cd \~/public\_html/mag2** .
</Note>

4. To permit access to the front-end store from a specific IP address while Magento is in maintenance mode, type the following command. Replace ***xxx.xxx.xxx.xxx*** with the IP address for which you want to allow access:

```bash theme={null}
bin/magento maintenance:allow-ips xxx.xxx.xxx.xxx
```

<Note>
  If you do not know your IP address, you can visit [http://ipfinder.us](http://ipfinder.us).
</Note>

5. To enable maintenance mode, type the following command:

```bash theme={null}
bin/magento maintenance:enable
```

Maintenance mode is now enabled. When you visit Magento from an authorized IP address, the store displays normally. All other site visitors, however, receive a **Service Temporarily Unavailable** message in their web browsers.

6. To disable maintenance mode and re-enable the store for all visitors, type the following command:

```bash theme={null}
bin/magento maintenance:disable
```

<Tip>
  To view the maintenance mode status at any time, type the following command:
</Tip>

```bash theme={null}
bin/magento maintenance:status
```

## Enabling maintenance mode in Magento 1.9 and older versions

To enable maintenance mode in Magento 1.9 and older versions, follow these steps:

1. Log in to your account [using SSH](/docs/using-ssh-secure-shell).

2. Change to the directory where you installed Magento. For example, if Magento is in the document root directory, type `cd ~/public_html`.

3. Use your preferred text editor to open the *index.php* file.

4. Locate the following line in the *index.php* file:

```
$maintenanceFile = 'maintenance.flag';
```

After this line, add the following two lines. Replace ***xxx.xxx.xxx.xxx*** with the IP address for which you want to permit access to the front-end store while  Magento is in maintenance mode:

```
$ip = $_SERVER['REMOTE_ADDR'];
$allowed = array('xxx.xxx.xxx.xxx');
```

<Note>
  * To allow multiple IP addresses, separate them with a comma. For example:
</Note>

```
$allowed = array('10.1.0.127', '10.1.0.252');
```

> * If you do not know your IP address, you can visit [http://ipfinder.us](http://ipfinder.us).

5. Locate the following line in the *index.php* file:

```
if (file_exists($maintenanceFile)) {
```

Change the line to look like the following:

```
if (file_exists($maintenanceFile) &&!in_array($ip, $allowed)) {
```

6. Save your changes to the *index.php* file and exit the editor.

7. At the command prompt, type the following command:

```bash theme={null}
touch maintenance.flag
```

Maintenance mode is now enabled. When you visit Magento from an authorized IP address, the store displays normally. All other site visitors, however, receive a **Service Temporarily Unavailable** message in their web browsers.

8. To disable maintenance mode and re-enable the store for all visitors, type the following command:

```bash theme={null}
rm maintenance.flag
```

## Related articles

* [Resetting the Magento administrator password](/docs/resetting-the-magento-administrator-password)

* [Optimizing Magento](/docs/optimizing-magento)
