More
More
503 Service Unavailable
The server cannot handle the request right now.
- Code
503- Reason phrase
- Service Unavailable
- Class
- 5xx Server error
- Defined in
- RFC 9110 section 15.6.4
- Cacheable by default
- No
What it means
Server error: the request may be fine, but the server failed to carry it out.
When a server should send it. When the server is temporarily unable to handle requests: maintenance, overload, every backend down. Add Retry-After when you know how long it will last. For planned maintenance this is the correct code for every URL, rather than a 200 maintenance page.
Common causes. Maintenance, overload or every backend being down.
What to do. Retry later, after the Retry-After time if given. A planned outage should return 503 so search engines do not drop the pages.
How clients and crawlers treat it
Browsers and HTTP clients. Browsers show the body. Clients and crawlers treat it as temporary and come back later.
Google Search. Googlebot treats 5xx responses as a sign of trouble and temporarily slows its crawl rate. Already indexed URLs are kept at first, but are dropped if the errors continue. This makes 503 with Retry-After the right response for planned maintenance; a long outage still ends with pages dropped. Source: Google Search Central, How HTTP status codes, and network and DNS errors affect Google Search.
Caching. Not cacheable by default (RFC 9110 section 15.1 does not list it). A cache stores it only when the response says so with Cache-Control or Expires.
Example response
HTTP/1.1 503 Service Unavailable Retry-After: 3600 Content-Type: text/html; charset=utf-8 Service Unavailable
How to send 503
location /example {
add_header Retry-After '3600' always;
return 503;
}
Header always set Retry-After "3600" RewriteEngine On RewriteRule ^example$ - [R=503,L]
header('Retry-After: 3600');
http_response_code(503);
echo 'Service Unavailable';
exit;
res.writeHead(503, { 'Retry-After': '3600', 'Content-Type': 'text/plain' });
res.end('Service Unavailable');
# in a view function
return 'Service Unavailable', 503, {'Retry-After': '3600'}
Change the paths to suit. In nginx, add_header needs always to apply to error responses.
Related codes
- 429Too Many RequestsThe client sent too many requests in a given time and is being rate limited.
- 502Bad GatewayA proxy, load balancer or CDN got an invalid response from the server behind it.
- 504Gateway TimeoutA proxy or CDN waited too long for the server behind it.
- 500Internal Server ErrorSomething went wrong on the server and it has no more specific code to give.
All status codes · All 5xx codes
Names and numbers from the IANA HTTP Status Code Registry. Google Search behaviour as documented by Google Search Central.