1. Home
  2. Magento Tutorials
  3. How to Enable Maintenance Mode in Magento

How to Enable Maintenance Mode in Magento

There will be times when you want to prevent visitors from accessing your online store. Perhaps you’re making adjustments to the site or adjusting a few settings before going live after importing a product list. You will need to change the system to go into “maintenance mode.”

Maintenance mode allows you to make those programming changes or additions without visitors accessing the information or committing sales when your website isn’t ready. This is especially useful if you have sections of coding open that could lead to a compromised website for hackers.

Unfortunately, Magento doesn’t have an easy way to take the site offline. Unless you buy an extension that includes this ability, you have to set maintenance mode manually. If you plan on making a lot of changes in the future, ¬†spending the money to install the module for maintenance mode would be a good investment.

Today, I’m going to show you how to enable maintenance mode in Magento using cPanel’s File Manager. Don’t worry, it’s only going to require a few copy and pastes from you to set this up.

Accessing Your Computer’s IP Address

In order to set maintenance mode for everyone except yourself, you need to find out your Internet connection’s IP address. This is relatively easy, especially if you’re used to using Google.

Go to Google’s website and type in “My IP Address” in the search bar.

Google My IP

This is your public IP address that will be detected by Magento. Should your address change, you will need the new address for the next steps.

Creating the Maintenance Mode File

In order for maintenance mode to activate, you need a file placed in the “var” directory of Magento.

From cPanel, click on the tool for File Manager.

File Manager Tool

Access your root directory for Magento. If you only have the eCommerce software installed, it will be located in the “public_html” directory.

Magento Root

Access the “var” folder in the directory to open its contents. You can do this by double clicking the folder icon.

Var Access

Click the “+ File” button on the top left of the File Manager.

Add File

In the New File Name, enter .maintenance.flag and click “Create New File.”

Create New Flag File

Right click the new file and select “Edit” from the drop down list. Mac users will press CMD and click. You can also select the file and click “Edit” from the top tool bar.

Edit File

You will now see a blank screen. On the first line of page, enter in the following code:

magento maintenance:enable ip=192.168.0.1


NOTE: Change the “192.168.0.1” to your Internet IP address you got from the Google search page from above.

Once you’ve entered the code, click the button to “Save Changes.”

Save Changes

What if you want to disable maintenance mode? Simply change “enable” to “disable” in the above within the .maintenance.flag file. You can also simply delete the file, but you may find it useful to leave active should you need to put the site in maintenance mode again in the future.

After all is said and done, it may be far easier to use a module specifically for enabling and disabling maintenance mode in Magento. At any rate, this is just one method to secure your Magento hosted website while making adjustments. This is better than the alternative of people and search engine bots stumbling across a broken site while you spend time fixing it.

Author: Josh Dargie

My name is Josh Dargie and I’m the Operations Manager at GreenGeeks. I’ve been with the company since 2009. I have over 16 years of experience working with and for various web hosting providers specifically in development, day-to-day operations and customer service.

Updated on May 17, 2017

Was this article helpful?

Related Articles

Add A Comment