Free auditStart free
GuideError · HTTP status codes

503 Service Unavailable in nginx

An nginx 503 is usually limit_req or limit_conn rejecting requests, a backend answering 503, or a deliberate return 503. Find which, with config to fix each.

5 min
read
9
sources
Nov 1, 2026
updated
Scaplet Editorial Team
author
The short answer

nginx itself returns 503 in two documented ways: limit_req and limit_conn reject excess requests with 503 by default, and return 503 sends it on purpose. A third source is the proxied backend, whose 503 nginx passes through. Find which rule fired by testing a burst of requests, then set limit_req_status, tune burst, or fix the backend.

  1. Three ways nginx ends up sending a 503
  2. Find the source in 2 minutes
  3. Fix a rate limit that rejects real users
  4. Fix a backend 503 that nginx passes through
  5. Send a maintenance 503 that crawlers understand
30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
01Which rule produced the 503

Three ways nginx ends up sending a 503

Unlike a 502 or 504, a 503 in nginx is often a decision rather than a failure. The rate-limiting modules choose it as their default rejection code, and a return 503; line chooses it for maintenance. Only the third source is a real fault: a proxied server that answers 503 itself.
Source

limit_req (request rate)

Default status
503, set by limit_req_status
How to recognize it
Fails only when one client or key sends faster than the zone's rate plus burst. Retrying a second later works
Source

limit_conn (concurrent connections)

Default status
503, set by limit_conn_status
How to recognize it
Fails when one key holds more open connections than limit_conn allows, for example during large downloads
Source

return 503; or an error_page 503 maintenance block

Default status
503
How to recognize it
Every request to that location fails, whoever sends it. Someone put it there
Source

Proxied backend (proxy_pass)

Default status
Whatever the backend sent
How to recognize it
The same URL fails with no nginx limit configured. The app or its server log shows the 503
Request path: where each source sits
client --> nginx
            |-- limit_req / limit_conn  -> 503 (default code), request never reaches the backend
            |-- return 503              -> 503, fixed response
            '-- proxy_pass --> backend  -> backend's own 503 passes back through nginx
02Fix it on your stack

Find the source in 2 minutes

Rate limits are per client, so test with a burst from one machine. The first command runs against a public test endpoint so you can see the output shape. The others need your own server and are marked.
Public test endpoint: confirm your client reads a 503 status
curl -sS -o /dev/null -w "%{http_code}\n" https://httpbin.org/status/503
# expected: 503
Your own server: fire 20 requests in a row (needs your domain)
for i in $(seq 1 20); do
  curl -sS -o /dev/null -w "%{http_code} " https://your-site.example/search/
done; echo
# Rate limit: a run of 200s, then 503s once the burst is used up
# return 503 or a dead backend: 503 every time
Your own server: what a single request returns (needs your domain)
curl -sS -D - -o /dev/null https://your-site.example/ | grep -i -E "^HTTP|^retry-after|^server"
# If you intend this 503 as maintenance, retry-after must be present

Then read the config. Search for limit_req, limit_conn, return 503 and error_page 503 across nginx.conf and included files with nginx -T | grep -n -E "limit_req|limit_conn|return 503|error_page 503". If none of them cover the failing location, the 503 is the backend's, so move to its own logs. The 503 pages for Apache and the generic 503 Service Unavailable cover that side.

03Your call

Fix a rate limit that rejects real users

The documentation's example allows an average of 1 request per second with bursts up to 5, and the default burst is zero. With a zero burst, two requests in quick succession from the same address can trip the limit, which is why a page that loads several assets from one path can hit 503. nodelay serves the burst immediately instead of spacing it out. The rejected status is configurable, and a dry run lets you measure before enforcing.
If this fits

Keep 503 as the rejection code when

  • Clients and monitors already treat 503 as retry later
  • The limit protects an expensive endpoint, not your whole site
  • You have no one counting 429s separately
Or

Switch to 429 when

  • You want rate-limit hits separate from real outages in logs and dashboards
  • Alerting on 5xx pages you for what is normal throttling
  • API clients expect 429 as the throttling signal
Adapted from the limit_req documentation, with a distinct rejection code
http {
    limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
    limit_req_status 429;

    server {
        location /search/ {
            limit_req zone=one burst=5 nodelay;
        }
    }
}
Measure first: count what would be rejected without rejecting it
location /search/ {
    limit_req zone=one burst=5;
    limit_req_dry_run on;
}

limit_req_dry_run appeared in nginx 1.17.1. In that mode requests are not limited, but excessive requests are still counted in the shared memory zone, and the $limit_req_status variable (1.17.6) reports PASSED, DELAYED, REJECTED or REJECTED_DRY_RUN. The default log level for refusals is error, set by limit_req_log_level. The connection limiter has matching limit_conn_status (default 503), limit_conn_dry_run and limit_conn_log_level.

05Check it

Send a maintenance 503 that crawlers understand

Return 503 from a location and serve a static page through error_page. The Retry-After header needs the always parameter: by default add_header only adds a header to responses with codes such as 200, 301 or 304, so without always it is silently skipped on a 503.

After nginx -t and a reload, run the single-request curl above: you should see HTTP/2 503 or HTTP/1.1 503 and a retry-after: 3600 line. Remove the return 503; block to end maintenance.

Maintenance mode: 503 with a page and Retry-After
server {
    listen 80;
    server_name example.com;
    root /var/www/example;

    error_page 503 /maintenance.html;

    location / {
        return 503;
    }

    location = /maintenance.html {
        internal;
        add_header Retry-After 3600 always;
    }
}
06Explained

What an nginx 503 means for crawlers

Google's documentation says 5xx and 429 responses prompt its crawlers to temporarily slow down, and that a 503 or 429 may carry Retry-After with a delay in seconds or a date. A rate limit does not know who is asking, so an aggressive limit_req can return 503 to a crawler as readily as to a visitor. Google also warns against serving these codes for longer than 1-2 days, because if the same URL keeps returning them for multiple days it may be dropped from the index. For finding affected URLs, see 5xx server errors.

Questions

Asked a lot.

3 questions people ask next, answered from the sources on this page.

01Why does nginx return 503 instead of 429 when I rate limit?

The default for both limit_req_status and limit_conn_status is 503. Set limit_req_status 429; or limit_conn_status 429; in the http, server or location block to return 429 instead.

02Does nginx retry a request when the backend returns 503?

Not by default. proxy_next_upstream defaults to error timeout, so a 503 response is passed back to the client. Add http_503 to that directive to try the next server in the upstream group.

03Why is my Retry-After header missing from the 503?

add_header only applies to certain response codes unless you add always. Write add_header Retry-After 3600 always; and keep it in the same location or level that serves the 503, because headers are inherited only when a level has no add_header of its own.

Sources · 9

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • nginx.org
  • google.com
  1. 01nginx documentation: ngx_http_limit_req_modulenginx.org · checked 2026-11-01
  2. 02nginx documentation: ngx_http_limit_conn_modulenginx.org · checked 2026-11-01
  3. 03nginx documentation: ngx_http_proxy_modulenginx.org · checked 2026-11-01
  4. 04nginx documentation: ngx_http_upstream_modulenginx.org · checked 2026-11-01
  5. 05nginx documentation: ngx_http_headers_modulenginx.org · checked 2026-11-01
  6. 06nginx documentation: ngx_http_rewrite_modulenginx.org · checked 2026-11-01
  7. 07nginx documentation: ngx_http_core_modulenginx.org · checked 2026-11-01
  8. 08nginx documentation: Command-line parametersnginx.org · checked 2026-11-01
  9. 09Google Search Central: Reduce the Google crawl ratedevelopers.google.com · checked 2026-11-01
Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane