How to Enable or Disable Maintenance Mode in Magento
With a big catalog of 234+ extensions for your online store
Maintenance Mode is a useful and important mode in Magento. If you want to temporarily disable your website to test your site before it goes live, or do maintenance tasks such as updating, fixing the bug, etc., you can enable the maintenance mode.
When your website is in maintenance mode, store visitors will receive a Service Temporarily Unavailable message in their web browser instead of the frontend store. However, it is able for authorized IP addresses to access and view the store normally. We also have a post on how to enable or disable the maintenance mode in Magento 2 via command line that you can take a look at.
So, in this article, I will give you the detailed instructions to enable/ disable maintenance in both Magento 1 and Magento 2.
Enable/ disable maintenance mode in Magento:
Enable or Disable Maintenance Mode in Magento 1
To enable/ disable maintenance mode, following the below steps:
- Log in to your Magento administrator account via SSH
- Change to the directory where Magento is installed. For example, if you install Magento in the document root directory, type cd ~/public_html
- Open the index.php file by using your preferred text editor.
- Place the following line in the index.php file:
$maintenanceFile = 'maintenance.flag';
Add the following two lines after this line. where xxx.xxx.xxx.xxx is the IP address for which you want to allow access to the front-end store while Magento is in maintenance mode
$ip = $_SERVER['REMOTE_ADDR'];$allowed = array('xxx.xxx.xxx.xxx');
Note:
To exempt multiple IP addresses from the maintenance model, separate them with a comma.
For example
$allowed = array('10.1.0.127','10.1.0.252');
In case you do not know your own IP address, you can access to http://ipfinder.us/
- Place the following line in the index.php file:
if (file_exists($maintenanceFile)) {
Change the line to look like the following:
if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {
-
Exit the editor after saving your changes to the index.php file.
-
Type the following command on the command prompt:
touch maintenance.flag
After going through these above steps, you set the able status for maintenance mode. Now once you access to Magento website from an authorized IP address, the store displays normally. However, a Service Temporarily Unavailable message will be shown in the web browsers of all other visitors.
- To disable maintenance mode and permit all visitors to access the frontend store, type the following command:
rm maintenance.flag
Enable or Disable Maintenance Mode in Magento 2
Firstly, let me show you how to enable/ disable the maintenance mode in Magento 2, following the below process.
Explain
Magento detects the maintenance mode as follows:
If var/.maintenance.flag
does not exist, the maintenance mode is off and Magento website runs normally.
If var/.maintenance.flag
exists, the maintenance mode is on.
However, the maintenance status also depends on the file var/.maintenance.ip
. This file will make some exceptions so the Magento 2 maintenance mode can be off even if the var/.maintenance.flag
exists.
Now, you will be instructed to enable or disable the maintenance mode by using the following commands.
Enable The Maintenance Mode in Magento 2
Command usage
php bin/magento maintenance:enable [--ip=<ip address>]
For example
php bin/magento maintenance:enable --ip=192.168.1.10 --ip=192.168.1.11
By using the above command, you will disable the maintenance mode for two IP addresses 192.168.1.10 and 192.168.1.11. The IP address of the developer who wants to debug your website is probably usually included in the above command.
Disable The Maintenance Mode in Magento 2
Command usage
php bin/magento maintenance:disable [--ip=<ip address>]
Show Maintenance Status
To know the current status of the maintenance mode, use the below command:
Command usage
php bin/magento maintenance:status
Exempt IP Addresses From Maintenance Mode
To allow access to the frontend store from a specific IP address while Magento website is in maintenance mode, type the following command:
Command usage
php bin/magento maintenance:allow-ips <ip address> .. <ip address> [--none]
For example
php bin/magento maintenance:allow-ips 192.168.1.10 192.168.1.11
Learn more: Enable or Disable maintenance mode via Command Line in Magento 2
Conclusion
The Maintenance Mode allows online stores to conduct tests and make essential adjustments by showing customers the unavailable notice instead of the usual front pages. We have shown you the shortest process to enable/ disable maintenance mode in Magento 2, and now it is your turn to do it. If you have any questions, feel free to ask us!
Our support team is enthusiastic about providing excellent Magento extensions for you with FREE Lifetime update, FREE 1-year support, risk-free 60-day money back. Let us help you quickly grow your online business!
Looking for
Customization & Development Services?
8+ years of experiences in e-commerce & Magento has prepared us for any challenges, so that we can lead you to your success.
Get free consultantRecent Tutorials
Change Store Email Addresses
Fix Magento 2 'Invalid Form Key. Please refresh the page'
Magento 2 Search Settings: Default Magento vs Mageplaza AJAX Search
Explore Our Products:
People also searched for
- magento maintenance mode
- magento 2 maintenance mode only frontend
- maintenance mode magento 2
- magento maintenance.flag
- disable maintenance mode magento 2
- magento 2 maintenance mode allow ip
- magento maintenance mode disable
- magento set maintenance mode
- take magento out of maintenance mode
- magento 2 maintenance mode allow ip not working
- disable maintenance mode magento
- magento 2 enable maintenance mode
- magento 1 maintenance mode
- magento disable maintenance mode
- new york magento store maintenance
- magento maintenance support
- magento2 maintenance mode
- magento enable maintenance mode
- magento store maintenance
- magento 2 maintenance mode access admin
- magento 2 set maintenance mode
- how to disable maintenance mode in magento 2
- maintenance flag magento 2
- maintenance mode magento
- magento maintenance mode allow ip
- magento 1 enable maintenance mode
- magento 2 maintenance services
- magento 2 check maintenance mode
- how to enable maintenance mode in magento 2
- magento 2 remove maintenance mode
- maintenance mode disable magento 2
- magento site maintenance mode
- magento maintenance service
- how to put magento in maintenance mode
- maintenance flag magento
- 2.2.x, 2.3.x, 2.4.x
Stay in the know
Get special offers on the latest news from Mageplaza.
Earn $10 in reward now!