How to enable Maintenance mode in Magento?

Create a file named as maintenance.flag and upload it to Magento home directory containing following code.

$maintenanceFile = ‘maintenance.flag’;

if (file_exists($maintenanceFile)) {
include_once dirname(__FILE__) . ‘/errors/503.php’;
exit;
}

To enable Maintenance mode in Magento, you would typically follow these steps:

  1. SSH Access or FTP Access: Firstly, you need access to your Magento installation directory via SSH or FTP.
  2. Navigate to Root Directory: Using your preferred method of access, navigate to the root directory of your Magento installation.
  3. Create Maintenance.flag File: Within the root directory, create a file named maintenance.flag. This file tells Magento that maintenance mode is enabled.
    bash
    touch maintenance.flag
  4. Verify Maintenance Mode: After creating the maintenance.flag file, maintenance mode should now be enabled. Users accessing your Magento store will see a maintenance page instead of the regular storefront.
  5. Disable Maintenance Mode: To disable maintenance mode and allow normal access to your store, simply delete the maintenance.flag file from the root directory.
    bash
    rm maintenance.flag

Alternatively, if you prefer a more GUI-based approach, you can also enable maintenance mode through the Magento Admin Panel by following these steps:

  1. Log in to your Magento Admin Panel.
  2. Navigate to System > Tools > Maintenance Mode.
  3. Toggle the option to enable maintenance mode.
  4. Save the changes.

Please note that the exact steps may vary depending on the Magento version you are using, but these general steps should work for most versions.