# 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.

Canonical: https://scaplet.com/errors/http/503/nginx

Guide nginx Error · HTTP status codes

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

503 5xx · Server error

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](#three-ways-nginx-ends-up-sending-a-503)
2. [Find the source in 2 minutes](#find-the-source-in-2-minutes)
3. [Fix a rate limit that rejects real users](#fix-a-rate-limit-that-rejects-real-users)
4. [Fix a backend 503 that nginx passes through](#fix-a-backend-503-that-nginx-passes-through)
5. [Send a maintenance 503 that crawlers understand](#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 with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F503%2Fnginx%20(%22503%20Service%20Unavailable%20in%20nginx%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F503%2Fnginx%20(%22503%20Service%20Unavailable%20in%20nginx%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F503%2Fnginx%20(%22503%20Service%20Unavailable%20in%20nginx%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fhttp%2F503%2Fnginx%20(%22503%20Service%20Unavailable%20in%20nginx%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

_01_Which 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
```

_02_Fix 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
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)
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)
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](/errors/http/503/apache) and the generic [503 Service Unavailable](/errors/http/503) cover that side.

**Not tested here**I could not run nginx in this environment, so the config below is adapted from the nginx documentation and not executed. Run `nginx -t` before you reload.

_03_Your 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](/glossary/rate-limiting)
- 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`.

_04_What those settings do, per the nginx docs

## Fix a backend 503 that nginx passes through

When `proxy_pass` targets a group of servers, nginx can try the next one if the first fails, but only for the cases you list. The default `proxy_next_upstream error timeout;` does not include `http_503`. The documentation also says a 503 response counts as an unsuccessful attempt toward `max_fails` only if `http_503` is specified in that directive.

Setting

### `max_fails=3` with `fail_timeout=30s`

Effect

Three unsuccessful attempts within 30 seconds mark the server unavailable for 30 seconds. The default is 1 attempt and 10 seconds

Setting

### `backup`

Effect

The server only receives requests when the primary servers are unavailable

Setting

### `proxy_next_upstream_timeout 10s`

Effect

Limits how long a request may keep being passed to the next server. The default `0` turns the limit off

Setting

### `non_idempotent` (not set above)

Effect

Without it, `POST`, `LOCK` and `PATCH` requests are not passed on once sent to an upstream server

Retry a 503 on the next server and mark a failing one unavailable

```
upstream backend { server backend1.example.com max_fails=3 fail_timeout=30s; server backend2.example.com max_fails=3 fail_timeout=30s; server backup1.example.com backup; } server { location / { proxy_pass http://backend; proxy_next_upstream error timeout http_503; proxy_next_upstream_timeout 10s; } }
```

**Retrying hides the real problem**Passing 503s to the next server keeps users working, but it does not tell you why a backend is overloaded. Keep an eye on the backend's own logs while you do it.

_05_Check 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; } }
```

_06_Explained

## 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](/seo-issues/server-errors-5xx).

Questions

## Asked a lot.

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

_01_ Why 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.

_02_ Does 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.

_03_ Why 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. 01 [nginx documentation: ngx_http_limit_req_module](https://nginx.org/en/docs/http/ngx_http_limit_req_module.html) nginx.org · checked 2026-11-01
2. 02 [nginx documentation: ngx_http_limit_conn_module](https://nginx.org/en/docs/http/ngx_http_limit_conn_module.html) nginx.org · checked 2026-11-01
3. 03 [nginx documentation: ngx_http_proxy_module](https://nginx.org/en/docs/http/ngx_http_proxy_module.html) nginx.org · checked 2026-11-01
4. 04 [nginx documentation: ngx_http_upstream_module](https://nginx.org/en/docs/http/ngx_http_upstream_module.html) nginx.org · checked 2026-11-01
5. 05 [nginx documentation: ngx_http_headers_module](https://nginx.org/en/docs/http/ngx_http_headers_module.html) nginx.org · checked 2026-11-01
6. 06 [nginx documentation: ngx_http_rewrite_module](https://nginx.org/en/docs/http/ngx_http_rewrite_module.html) nginx.org · checked 2026-11-01
7. 07 [nginx documentation: ngx_http_core_module](https://nginx.org/en/docs/http/ngx_http_core_module.html) nginx.org · checked 2026-11-01
8. 08 [nginx documentation: Command-line parameters](https://nginx.org/en/docs/switches.html) nginx.org · checked 2026-11-01
9. 09 [Google Search Central: Reduce the Google crawl rate](https://developers.google.com/crawling/docs/crawlers-fetchers/reduce-crawl-rate) developers.google.com · checked 2026-11-01

## Keep learning

[All errors](/errors)

[Learn 503 Service Unavailable in Apache HTTP status codes](/errors/http/503/apache) [Related 5xx server errors Status codes and links](/seo-issues/server-errors-5xx) [Read next 503 Service Unavailable HTTP status codes](/errors/http/503) [Do Run a free site audit Free, about two minutes](/site-audit)

Other 503 errors
[503 Service Unavailable](/errors/http/503) [503 Service Unavailable in Apache](/errors/http/503/apache) [503 Service Unavailable in IIS](/errors/http/503/iis) [503 Service Unavailable in WordPress](/errors/http/503/wordpress) [503 Service Unavailable on Squarespace](/errors/http/503/squarespace)

More in 503 Service Unavailable
[503 Service Unavailable in Apache](/errors/http/503/apache) [503 Service Unavailable in IIS](/errors/http/503/iis) [503 Service Unavailable in nginx](/errors/http/503/nginx) [503 Service Unavailable in WordPress](/errors/http/503/wordpress) [503 Service Unavailable on Squarespace](/errors/http/503/squarespace)

Terms on this page
[Rate limiting](/glossary/rate-limiting)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

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

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
