Skip to content
NewRedesigned blogFeedback
Jigar Karangiya

How to Enable Maintenance Mode in Magento 2?

Enabling maintenance mode in Magento 2 is a crucial step when performing updates or troubleshooting your store. This mode allows you to take your site offline temporarily, ensuring that customers don’t encounter issues during your work. In this guide, we’ll walk you through the process of enabling and disabling maintenance mode, and show you how to exclude specific IP addresses for testing.

How to Enable Maintenance Mode in Magento 2?
Written by
JKJigar Karangiya
Published
Reading time
2 min read

Jigar Karangiya · · 2 min read

In this blog, we’ll walk you through the process of enabling maintenance mode in Magento 2, ensuring a seamless experience for both you and your customers.

Maintaining your Magento 2 store is crucial to ensure it runs smoothly and efficiently. Whether you’re updating the system, installing new extensions, or fixing bugs, it’s essential to place your site in maintenance mode to prevent visitors from encountering errors.

What is Maintenance Mode in Magento 2?

Maintenance mode is a feature in Magento 2 that allows you to temporarily take your store offline while performing updates or maintenance tasks. When enabled, visitors will see a customizable maintenance page, while you and your team can still access the backend to work on the site.

Why Should You Use Maintenance Mode?

Using maintenance mode is essential for preventing customers from encountering errors, broken pages, or incomplete transactions during updates. It provides a controlled environment where you can work on the site without impacting the user experience.

How to Enable Maintenance Mode in Magento 2?

Step 1: Access Your Magento 2 Root Directory

To enable maintenance mode, you’ll need to access the Magento 2 root directory via SSH or FTP. If you’re using SSH, connect to your server using a terminal and navigate to the root directory of your Magento 2 installation.

RunTerminal
cd /path/to/magento/root

Step 2: Enable Maintenance Mode

Once you’re in the root directory, use the following command to enable maintenance mode:

RunTerminal
php bin/magento maintenance:enable

This command creates a **.maintenance.flag** file in the **var** directory, signaling that maintenance mode is active. (This is a hidden file)

Figure 01

Step 3: Verify Maintenance Mode is Enabled

After running the command, your store will display a default maintenance page to visitors. You can verify that maintenance mode is enabled by visiting your store’s frontend.

Figure 02

How to Exclude Specific IP Addresses from Maintenance Mode

You may need to access the frontend for testing purposes while the site is in maintenance mode. To do this, you can exclude your IP address from maintenance mode by adding it to the **var/.maintenance.ip** file.

Figure 03
RunTerminal
php bin/magento maintenance:allow-ips [your_IP_address]

For example:

RunTerminal
php bin/magento maintenance:allow-ips 192.168.1.1

This command will allow the specified IP address to access the frontend, bypassing maintenance mode.

How to Disable Maintenance Mode

Once your maintenance tasks are complete, you can disable maintenance mode by running the following command:

RunTerminal
php bin/magento maintenance:disable

This command removes the **.maintenance.flag** file, and your store will be accessible to all visitors.

If you found this guide helpful, don’t forget to share it with your fellow Magento 2 developers! For more Magento 2 tips, tricks & tutorials, subscribe to our blog and stay updated.

Reference Link :

https://experienceleague.adobe.com/en/docs/commerce-operations/installation-guide/tutorials/maintenance-mode (opens in new tab)

You may also like,

How to Get Admin URL in Magento 2

How to Use ViewModel in Magento 2: A Simple Guide

Magento 2: How to use helper in PHTML?

How to Remove Sample Data from Magento 2

Keep reading
All posts

01 · 10 min · Shares Adobe Commerce Core

Adobe Commerce Agentic Capabilities, Q4 2026

Five agentic releases for Adobe Commerce: LLM product discovery, Brand Visibility, the Shopper MCP server, Brand Concierge, and Experience Workspace. What each one does, which editions get it, and when.

10 min

03 · 3 min · Shares Adobe Commerce Core

Conditions for Collections in Magento 2

Collections in Magento 2 (Now Adobe Commerce), are among the most powerful tools for retrieving and manipulating data directly from the database.

3 min

Newsletter

New Magento tutorials, straight to your inbox

Code examples, performance tips, and fixes for common Magento issues. No spam.

Subscribe