Skip to content

Enable or Disable Magento 2 Maintenance Mode using CLI / Command Prompt or Files

What is the magento maintenance mode ?

When Magento is in maintenance mode, visitors see a Service Temporarily Unavailable message in their web browsers instead of the store. However, authorized IP addresses can still view the store normally.

You can enable maintenance mode using two methods.

How to enable magento maintenance mode using cli / command prompt / terminal.

Login to your server using SSH or terminal that is available to you.

change the directory to your Magento store root folder

magento-enable-maintenance-mode-cli-command-prompt

 

 

Then type in the below command and press enter to enable the maintenance mode for everyone.

bin/magento maintenance:enable

enable the maintenance mode for everyone

 

 

 

Now everyone visiting the website will see a Service Temporarily Unavailable message like below.

magento-enable-maintenance-website-viewHow to enable magento maintenance mode for everyone except few IP addresses ( or yourself)

You can also enable the maintenance mode for everyone except a few known IP addresses. This option is useful for fixing a bug on a live website.  Using this method a developer/admin can view the Magento website while other people will see a site under maintenance banner.

1st find out your computers IP address. Easiest way is to go to Chrome and search for “What is my IP address” : click here to search

what-is-my-ip-address-google-searchNow enter below command with your IP address like below .

bin/magento maintenance:enable --ip xxx.xxx.xxx.xxx

The magento website will be now under maintenance mode except for the specified IP.

magento-enable-maintenance-mode-cli-command-prompt-for-specific_ip

 

 

How to disable Magento maintenance mode using CLI / Command Prompt / Terminal

Login to your server using SSH or terminal that is available to you.

change the directory to your Magento store root folder

magento-enable-maintenance-mode-cli-command-prompt

 

 

Then type in the below command and press enter to enable the maintenance mode for everyone.

bin/magento maintenance:disable

 

 

Now the Magento “Service Temporarily Unavailable” message will be gone and the normal website will be shown.

How to enable/disable Magento maintenance mode file “maintenance.flag”

If you dont have access to SSH terminal, still you can enable magento maintenance mode by creating a blank file named “maintenance.flag” under the magento root folder using a FTP client.

To disable magento maintenance mode , delete the file “maintenance.flag” under your magento root folder.