503 Service Unavailable means: The server is temporarily unable to handle the request — overloaded or down for maintenance. The key word is temporary: Retry-After can indicate when to come back, and clients should treat it as a backpressure signal rather than a permanent failure. Server-error 5xx codes mean the server failed while trying to fulfill a valid request. The fault lies with the service or its upstreams, not the caller. Some members are transient and retryable with backoff; others indicate bugs or configuration errors that only the operator can fix. In practice you will meet 503 when traffic exceeds capacity and the server sheds load; a maintenance window or deployment takes the service offline; a dependency pool (db connections, workers) is exhausted and the app fails fast. On the client side, honor Retry-After and back off with jitter; do not retry-storm an overloaded service — that deepens the outage. Cache or degrade gracefully where possible. On the server side, return Retry-After with a realistic estimate, shed load early and consistently, and serve a static maintenance page from the edge when the origin is down.
When 503 happens
- Traffic exceeds capacity and the server sheds load
- A maintenance window or deployment takes the service offline
- A dependency pool (DB connections, workers) is exhausted and the app fails fast
How to fix it
On the client
Honor Retry-After and back off with jitter; do not retry-storm an overloaded service — that deepens the outage. Cache or degrade gracefully where possible.
On the server
Return Retry-After with a realistic estimate, shed load early and consistently, and serve a static maintenance page from the edge when the origin is down.
Should you retry?
Retryable after Retry-After; do not retry-storm an overloaded service.
Debugging steps
When 503 appears unexpectedly, start by capturing the full exchange: 'curl -i' or the browser DevTools Network tab shows the exact status line and response headers, which often carry the real explanation. Determine whether the error came from the edge or the origin: a proxy-generated error page looks different from your app's. Then trace upstream health, timeouts and recent deployments. For this code specifically, check whether the most common trigger applies to your situation: traffic exceeds capacity and the server sheds load. Compare your exchange against the raw HTTP example above. If you operate the server, correlate the timestamp with application and proxy logs using the request id; if you are the client, verify the request shape against the API documentation before changing anything or retrying.
Notes & gotchas
503 is whole-service backpressure, not per-client punishment: everyone must wait, so retry storms deepen the outage. Honor Retry-After and shed load early and consistently.
Examples
HTTP/1.1 503 Service Unavailable
Retry-After: 60
Content-Type: application/json
Content-Length: 103
{
"error": "service_unavailable",
"message": "Traffic exceeds capacity and the server sheds load"
} curl -i https://api.example.com/v1/resource # observe the 503 response and its headers const res = await fetch("https://api.example.com/v1/resource");
if (res.status === 503) {
const wait = Number(res.headers.get("Retry-After") ?? 5);
await new Promise(r => setTimeout(r, wait * 1000));
// retry with exponential backoff + jitter; cap attempts
return retryWithBackoff();
} import time
import requests
res = requests.get("https://api.example.com/v1/resource", timeout=10)
if res.status_code == 503:
wait = int(res.headers.get("Retry-After", 5))
time.sleep(wait) # then retry with exponential backoff + jitter
# consider requests.adapters.HTTPAdapter(max_retries=Retry(...)) for automation Frequently asked questions
503 vs 429: both mean 'slow down'?
429 is per-client rate limiting (you specifically sent too much). 503 is whole-service unavailability (everyone must wait), regardless of your individual rate.
Is 503 always retryable?
Yes, by definition it is temporary — but respect Retry-After and cap attempts; a service in a long maintenance window should not be hammered.
Are 5xx errors safe to retry?
Idempotent requests (GET, PUT, DELETE) generally yes, with exponential backoff and jitter. Non-idempotent POSTs need care: a 504 may mean the work completed upstream. Check state or use idempotency keys before retrying.
Who should fix a 5xx — the caller or the provider?
The provider: 5xx asserts a server-side fault. Callers can only retry politely (backoff, idempotency) and report correlation ids; persistent 5xx need operator action on logs, upstreams or configuration.
Try the JSON Validator
Check JSON syntax and locate errors by line and column.