Introduction

Magento has a built-in maintenance mode that lets store owners temporarily take their website offline for updates, security fixes, or migrations. This prevents customers from seeing broken pages or errors. You can also customize the maintenance page to keep visitors informed about the downtime and when the site will be back.

Enabling Maintenance Mode in Magento

Enabling maintenance mode is straightforward in Magento. Use the following command from your Magento root directory:

  • php bin/magento maintenance:enable
  • Once executed, visitors will see a default Magento 503 Service Unavailable page.
  • To check the maintenance mode status, use:
  • php bin/magento maintenance:status
  • If enabled, you will see:
  • Maintenance mode is active.

Allowing Specific IPs to Access the Store

By default, when maintenance mode is enabled, no visitors can access the site. However, you may want to allow certain IP addresses (e.g., developers, administrators) to bypass maintenance mode and access the store.

  • Use the following command to whitelist an IP:
  • php bin/magento maintenance:allow-ips <your-ip-address>
  • For example, to allow an admin with IP 192.168.1.100, run:
  • php bin/magento maintenance:allow-ips 192.168.1.100
  • To allow multiple IPs, separate them with spaces:
  • php bin/magento maintenance:allow-ips 192.168.1.100 192.168.1.101
  • To verify allowed IPs:
  • php bin/magento maintenance:status
  • If IPs are allowed, the output will include:
  • Maintenance mode is active.
  • Allowed IPs: 192.168.1.100, 192.168.1.101
  • To remove all allowed IPs and restrict access for everyone:
  • php bin/magento maintenance:allow-ips –none

Customizing the Magento Maintenance Page

  • Magento’s default maintenance page is located at:
  • pub/errors/default/503.phtml
  • To create a custom maintenance page:

Modify the custom page Open pub/errors/503.phtml and update the content with a user-friendly message. Example:

After modifying the page, clear Magento’s cache to reflect changes:

  • php bin/magento setup:static-content:deploy -f
  • php bin/magento cache:flush

Disabling Maintenance Mode

  • Once maintenance is completed, disable it with:
  • php bin/magento maintenance:disable

Check the status to confirm:

  • php bin/magento maintenance:status

If disabled, the output will be:

  • Maintenance mode is not active.

Troubleshooting Maintenance Mode Issues

1. Site Still in Maintenance Mode After Disabling?

  • Check if the var/.maintenance.flag file still exists. If it does, remove it manually:rm var/.maintenance.flag

2. Getting 503 Errors After Maintenance Mode is Disabled?

Try clearing cache and restarting your web server:

  • php bin/magento cache:flush

Conclusion

Magento’s maintenance mode is a powerful feature that allows store owners to perform updates without disrupting user experience. By customizing the maintenance page, you can keep your customers informed and ensure a professional look even during downtime.

Leave a Reply