Magento maintenance mode: How to enable/disable and improve it in your Magento website

Magento maintenance mode

Magento maintenance mode is a helpful and crucial mode in Magento 2. If you want to provisionally disable your Magento store to test your website before it goes live, or make maintenance tasks including updating, fixing the bug, etc., you can enable the maintenance mode. When your online store is in maintenance mode, users will get a Service Temporarily Unavailable message in their web browser instead of the frontend store. However, it is possible for access from authorized IP addresses to view the store normally.

A quick reminder: We’ve just released the version 2.0 of Claue Multipurpose Magento 2 Theme, with with a bunch of performance improvements and exclusive features. Check this theme out now: Claue Magento Theme  2. 0 

claue2_edited (1)

Live Demo 

Claue – Clean, Minimal Magento 2&1 Theme is an excellent template for a modern and clean eCommerce store with 40+ homepage layouts and tons of options for shop, blog, portfolio, store locator layouts and other useful pages. Claue version 2. 0  has been released with a bunch of performance improvements and exclusive features including:

  • Being based on Luma theme.
  • Meet all standards of Magento Theme
  • Significant performance improvement
  • Compatible with most third-party extensions.
  • Fully compatible with Magento 2.4.x

So, let’s get to the main topic, shall we?

What Is Magento 2 Maintenance Mode?

Magento maintenance mode lies among one of the 4 basic modes of Magento, including default, developer, production, and maintenance. Your Magento 2 website’ operation is based on these 4 modes. The table shows details:

Default: This mode enable to deploy the Magento application on a single server without any setting adjustment. However, if you want to optimize production or set up applications on multiple servers, you need to consider using a different mode instead of the default

Developer: For development only.

Production: Be suitable for Magento deployment on a production server

Maintenance:  To prevent access to the Magento Commerce website that is in the process of being upgraded or restructured.

  • Redirects site users to a default Service Temporarily Unavailable page.
  • Under maintenance mode, the var/ directory includes the .maintenance.flag file.
  • You can enable the Magento 2 maintenance mode to allow specific IP.

Magento maintenance mode is helpful  when you intend to develop and test your store before it goes “live,” or do other maintenance tasks, such as installing updates without being noticed by users. In other ways, if you enable this mode, your site will be temporarily offline and take users to a default Service Temporarily Unavailable page.

Normally, you can customize your Magento 2 website without having to put it in Magento maintenance mode. Some minor changes such as publishing new content, updating themes and plugins can still take place while not causing the website death. However, some works take you a long time to complete. For instance, when you manually configure a new theme or a new extension to adjust the behavior on your  site

If your site has a lot of traffic, you do not want your users (your potential customers) to see a broken website. This will lead to a negative impression on your business and negatively affect the customer experience. That is the reason why this function was born.

How to improve Magento maintenance mode?

Magento maintenance mode allows you to restrict visitors access to your website while making site maintenance. Unfortunately, it also freezes you out of the website. Incuding the following code to your index.php file to help you to work on your online stote while everyone else sees maintenance mode


Open index.php. Above line 64 and add the below command and include the IPs to retain access to the site in the “allowed” array:

allowed = array(’’,’’);

Locate and adjust the line:

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

Save the file.

Cloudflare method

If using Cloudflare, add the below command to you index.php file instead:

allowed = array(’’,’’);

Enable or Disable Maintenance Mode in Magento 2

To enable/ disable tMagento maintenance mode, you need to follow the below process.


Magento 2 detects the maintenance mode as follows:

If var/.maintenance.flag does not exist, the maintenance mode is off and Magento website run commonly.

If var/.maintenance.flag exists, the maintenance mode is on.

However, the maintenance status also rely on the file var/.maintenance.ip. This file will do some exceptions so the Magento 2 maintenance mode can be off even if the var/.maintenance.flag exists.

By using the following commands, you can enable and disable the maintenance Mode in Magento 2

1. Enable Magento maintenance mode

Command usage

php bin/magento maintenance:enable [--ip=<ip address>]

For example

php bin/magento maintenance:enable --ip= --ip=

Following the above command, you will disable the maintenance mode for 2 IP address and The IP address of the programmer who need to debug your site is probably usually contained in the above command.

2. Disable Magento maintenance mode

Command usage

php bin/magento maintenance:disable [--ip=<ip address>]

Show Maintenance Status

To know the current status of the maintenance mode, follow the below command:

Command usage

php bin/magento maintenance:status

Exempt IP Addresses From Maintainance Mode

To enable access to the frontend store from a specific IP address while Magento 2 website is in maintenance mode, use the below command:

Command usage

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

For example

php bin/magento maintenance:allow-ips


Above are the shortest method for you to enable/ disable Magento maintenance mode. Whether you are wondering why your Magento 2 website needs to be under maintenance mode or the settings make you a headache, don’t hesitate to contact us.

Besides, if you are looking out for a cost effective Magento package for your eCommerce store, then look nowhere other than Magesolution. We not only offer an affordable Magento Development Package for all size and budget but also ensure that it helps your online business grow and sustain. Contact us for a free consultation!

2850 Total Views 6 Views Today