Step 1: Choose the correct working directory
Before you can enable Magento 2 maintenance mode, follow these steps:
- Login to your SSH account
- Enter this command at the command prompt:
If you’ve installed Magento 2 in a subdirectory, you need to point to that directory. For example, if you’ve installed Magento in the subdirectory named
mag1, you should type:
Step 2: Allow an IP address to access your store
To allow Magento storefront access from a specific IP address while your website is in maintenance mode, enter the command:
bin / magento maintenance: allow-ips xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx is the IP address you want to allow access to.
Example 1: To enable Magento website maintenance with no IP address exemptions:
Example 2: To enable maintenance mode for all clients except 22.214.171.124 and 126.96.36.199:
bin/magento maintenance:enable --ip=188.8.131.52 --ip=184.108.40.206
- To remove multiple IP addresses in the same command, you can use the
--ip=<ip address> option multiple times.
- To remove the list of exempt IPs, you can use
magento maintenance: enable --ip=none.
If you don’t know your IP address, you can go to IPfinder.
Step 3: Enable maintenance mode in Magento 2
To enable Magento website maintenance for a store, enter the following command:
Then, all visitors will then receive a Service Temporarily Unavailable message in their web browser. However, if you access Magento from an authorized IP address, the store will display normally.
If you have multiple stores with different localization and layout, pass the
$_GET['skin'] parameter to the intended processor. After that, make sure you have Nginx installed for those stores.
Step 4: Use maintenance template file for localized content