We are aware of a potentially service impacting issue. Learn more

Magento 1: How do I make my Magento site temporarily unavailable (put into maintenance mode)? Print

  • 3

There may be times when you need to perform an upgrade and don't want your website to be accessed during that time. This is important when performing updates that affect the database. When maintenance is being performed, Google search engine rankings could potentially drop, since Googlebot cannot crawl your site.

Using maintenance.flag

The preferred, and easiest approach, is to create a new empty file in your Magento root directory named maintenance.flag. Magento will then automatically display a maintenance page with a 503 header. A 503 HTTP result code will tell Google that your site is temporarily unavailable. For Create Hosting customers on a Magento hosting plan (such as Mage Lite, Mage Plus or Mage VPS), your Magento cron jobs / scheduled tasks are pre-configured to look for the presence of this file and won't execute when the file is present.

Using .htaccess and a 503.php page

Alternatively, you can also create your own 503.php page, along with a .htaccess file and use an optional Retry-After header, which will inform Googlebot when it should attempt to re-visit your site.

Here is an example of restricting access to your website to your computer IP address only. Other visitors (including Googlebot and other search engine spiders) will get the HTTP 503 Service Unavailable error. Make sure you set the date as appropriate though.

1. Create a file 503.php in your Magento installation root:

header('HTTP/1.1 503 Service Unavailable');
header('Content-Type: text/plain; charset=UTF-8');
header('Retry-After: Tues, 29 Jun 2011 12:00:00 EST');
echo "503 Service Unavailable";

2. In .htaccess, add the following rewrite rule:

RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1$
RewriteRule !503.php$ /503.php [L]

Where (note the backslashes before dots) should be replaced with your IP address. You can Google your IP Address using https://www.google.co.nz/search?q=what+is+my+ip

Once you save this .htaccess file, your site will be down until you restore the initial state (just comment out or remove the above 3 lines in your .htaccess file).

Using Nginx and a 503.php page

With Nginx, .htaccess will be ignored. You can however use the following in your Nginx configuration instead:

# redirect to 503 maintenance page
location / {
if ($remote_addr !~ "^127\.0\.0\.1$"){
rewrite !503.php$ /503.php break;


For Create Hosting Magento customers using Nginx, drop in a support ticket and we'll get that setup for you. 

Was this answer helpful?

« Back