Reading list Switch to dark mode

    Maintenance mode in Magento2

    Updated 18 March 2024

    What is Maintenance Mode in Magento2

    Maintenance Mode in Magento 2 is a feature that allows administrators to temporarily restrict access to their online store while performing maintenance tasks or making significant changes to the website. When Maintenance Mode is enabled, visitors to the website are presented with a custom maintenance page instead of the regular storefront.

    Command to check the Maintenance mode status

    We can check whether the maintenance mode is enabled or disabled from the following command in Magento2:

    php bin/magento maintenance:status

    running the above command output:
    Status: maintenance mode is not active
    List of exempt IP-addresses: none

    This shows that maintenance mode is not enabled on the Magento site.

    Command to Enable the Maintenance mode

    We can enable the maintenance mode from the following command in Magento2:

    Searching for an experienced
    Magento 2 Company ?
    Find out More
    php bin/magento maintenance:enable

    running the above command output:
    Enabled maintenance mode

    Command to Enable the Maintenance mode for specific IP addresses

    Activating maintenance mode typically applies restrictions to all IP addresses, displaying the maintenance page to all users attempting to access the website.
    But there is a situation/requirement that we want to give access to frontend site to the particular user.

    For example, if you need to provide access to the website developer during maintenance, you must include their IP address in the allowed list. This allows anyone from the specified IP addresses to access the site despite maintenance mode being active, while other users will encounter the maintenance page.

    We can set as many as IP addresses as we want

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

    the above command output:
    Enabled maintenance mode
    Set exempt IP-address: 192.168.0.107,192.168.0.108

    if you again check the status of the Maintenance mode via command line

    php bin/magento maintenance:status

    then the output will be:
    Status: maintenance mode is active
    List of exempt IP-addresses: 192.168.0.107,192.168.0.108

    this shows that Maintenance mode is active and only two given IP addresses(192.168.0.107,192.168.0.108) can access the frontend site and the rest users only see the Maintenance page.

    Command to remove all IP addresses from the exempt list

    php bin/magento maientenace:enable --ip=none

    the above command output is:
    Enabled maintenance mode
    Set exempt IP-addresses: none

    means no user from any IP address is allowed to access the frontend of the website.

    Command to disable the Maintenance mode

    php bin/magento maintenance:disable

    the above command output is:

    Disabled maintenance mode

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home