This tutorial explains how to put your Magento online store in maintenance mode so your visitors know that you're working on your website. To put a Magento site in maintenance mode, you need to create an empty .maintenance.flag file and upload it to the var/ folder of your site. Make sure not to miss the dot in front of the filename. After that your web site will look like this:
Note that once you enable maintenance mode, you won't be able to access both the front and backend of your website. In case you want to access the website while in maintenance mode, you will need to add a .maintenance.ip file in the var/ folder. The file should contain the IP address from which the website should be accessed. Thus only when visited from that IP address, the website will not show the maintenance page.
When you decide to disable the maintenance mode - just remove the .maintenance.flag and .maintenance.ip files.
Another option to enable maintenance mode is by logging via SSH and running the following command:
php bin/magento maintenance:enable --ip=0.0.0.0
The 0.0.0.0 IP address acts like a variable here and you should make sure to substitute it with your IP address.
You may also disable it via a similar command which is as follows:
php bin/magento maintenance:disable