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.
Why Use Maintenance Mode?
-
Prevents customers from seeing errors during updates.
-
Protects data integrity while applying patches or extensions.
-
Allows developers to test changes safely.
Enabling Maintenance Mode in Magento 2
-
Log in to your hosting account via SSH.
-
Navigate to your Magento installation directory:
Bash cd ~/public_html(If installed in a subdirectory, adjust accordingly, e.g.
cd ~/public_html/mag2) -
To allow access from a specific IP address while in maintenance mode:
Bash bin/magento maintenance:allow-ips xxx.xxx.xxx.xxx(Replace
xxx.xxx.xxx.xxxwith your IP address. You can find it at http://ipfinder.us) -
Enable maintenance mode:
Bash bin/magento maintenance:enable -
To disable maintenance mode and re‑enable the store for all visitors:
Bash bin/magento maintenance:disable -
To check the current status:
Bash bin/magento maintenance:status
Enabling Maintenance Mode in Magento 1.9 and Older
-
Log in to your hosting account via SSH.
-
Navigate to your Magento installation directory:
Bash cd ~/public_html -
Open the
index.phpfile in a text editor. -
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.)
-
Modify the conditional statement:
if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) { -
Save changes and exit the editor.
-
Enable maintenance mode:
Bash touch maintenance.flag -
Disable maintenance mode:
Bash rm maintenance.flag
Important Notes
-
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.