Skip to content

Enabling Magento Maintenance Mode

Magento’s maintenance mode allows you to temporarily take your store offline while performing updates, testing, or development. During this time, visitors see a “Service Temporarily Unavailable” message, while authorized IP addresses can still access the store normally. On ruachost.com, you can enable maintenance mode for both Magento 2 and Magento 1.x.

  • Prevents customers from seeing errors during updates.
  • Protects data integrity while applying patches or extensions.
  • Allows developers to test changes safely.
  1. Log in to your hosting account via SSH.

  2. Navigate to your Magento installation directory:

    Terminal window
    cd ~/public_html

    (If installed in a subdirectory, adjust accordingly, e.g. cd ~/public_html/mag2)

  3. To allow access from a specific IP address while in maintenance mode:

    Terminal window
    bin/magento maintenance:allow-ips xxx.xxx.xxx.xxx

    (Replace xxx.xxx.xxx.xxx with your IP address. You can find it at http://ipfinder.us)

  4. Enable maintenance mode:

    Terminal window
    bin/magento maintenance:enable
  5. To disable maintenance mode and re‑enable the store for all visitors:

    Terminal window
    bin/magento maintenance:disable
  6. To check the current status:

    Terminal window
    bin/magento maintenance:status

Enabling Maintenance Mode in Magento 1.9 and Older

Section titled “Enabling Maintenance Mode in Magento 1.9 and Older”
  1. Log in to your hosting account via SSH.

  2. Navigate to your Magento installation directory:

    Terminal window
    cd ~/public_html
  3. Open the index.php file in a text editor.

  4. Add the following lines after the $maintenanceFile = 'maintenance.flag'; line:

    $ip = $_SERVER['REMOTE_ADDR'];
    $allowed = array('xxx.xxx.xxx.xxx'); // Replace with your IP

    (To allow multiple IPs, separate them with commas.)

  5. Modify the conditional statement:

    if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {
  6. Save changes and exit the editor.

  7. Enable maintenance mode:

    Terminal window
    touch maintenance.flag
  8. Disable maintenance mode:

    Terminal window
    rm maintenance.flag
  • Always back up your site before performing updates.
  • Authorized IPs allow developers/admins to continue working while customers see the maintenance page.
  • Maintenance mode is essential when applying patches, upgrading Magento, or installing new extensions.