116

Is there a HTTP status code to tell Google (and others) to go away, index me again later?

Basically, one that semantically tells clients that the site is down for maintenance?

The ones I have considered are

304 => Not modified
307 => Temporary redirect
410 => Gone
503 => Service Unavailable

I'm leaning towards the last one, but was just curious as to which one was proper choice.

Harshal Parekh
  • 5,918
  • 4
  • 21
  • 43
alex
  • 479,566
  • 201
  • 878
  • 984

5 Answers5

142

HTTP 503 - Service Unavailable would be the most appropriate.

The Web server (running the Web site) is currently unable to handle the HTTP request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay.

This post on the Google Webmaster Central Forum is also relevant:

Yes - a 503 is the correct server response for "We're closed". If you substitute a normal HTML page saying "We're closed" and serve a 200 it's very likely to get indexed by Google.

If you give the Googlebot a 503, it will just go away and come back later without indexing what you give it.


UPDATE:

As for the php implementation, you may be interested in checking out the following article:

Also notice the retry-after header, where you can specify after how many seconds another request should be re-attempted.

VMC
  • 1,378
  • 4
  • 16
  • 32
Daniel Vassallo
  • 337,827
  • 72
  • 505
  • 443
  • 2
    Looks like this is no longer working with http2 - when I send a 503 with the maintenance page, Chrome shows an ERR_HTTP2_PROTOCOL_ERROR. If I send a 200, everything is fine – Xosofox Nov 04 '19 at 15:25
  • 1
    @Xosofox Today I tested HTTP 503 serving a customized error page from Apache 2.4 and it worked well in all browsers. **MacOS 11 Big Sur** ✅ Safari 16.4.1 ✅ Chrome 113.0.5672.92 ✅ Firefox ✅ 113.0.1. **iOS 15.7.5**: ✅ Mobile Safari 15.6. **ChromeOS 113**.0.5672.114: ✅ Chrome (same version as OS). **Windows 10**: ✅ Edge 113.0.1774.42. – porg May 16 '23 at 10:48
  • Note: I did this with a maintenance `.htaccess` with a `RewriteRule .* - [R=503,L]` to rewrites all requests (`RewriteCond` It is NOT the error document itself or any of the special service URLs which continue to run independent from main CMS) serving a custom error document for the HTTP 503 status code with `ErrorDocument 503 /maintenance.html`. – porg May 16 '23 at 10:50
9

From http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=40132

503 (Service unavailable) The server is currently unavailable (because it is overloaded or down for maintenance). Generally, this is a temporary state.

Lee
  • 145
  • 1
  • 1
  • 5
4

I'd consider the 503 to be most appropriate, since the 5xx-group is meant for server errors in general.

Ham Vocke
  • 2,942
  • 22
  • 27
4

503 Service Unavailable

dan04
  • 87,747
  • 23
  • 163
  • 198
0

503 Service Unavailable

as 5XX series belongs to server-side issues