October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

504 vs. 503: What Triggers Each in nginx, ALB, and Cloudflare

A 503 signals temporary unavailability; a 504 signals an upstream timeout. Neither identifies the source by itself. Compare response clues, timings, target status, and logs across nginx, ALB, Cloudflare, and the origin.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A 503 Service Unavailable usually means a service cannot serve the request at that moment, often because it lacks ready capacity. A 504 Gateway Timeout means a gateway or proxy did not receive an upstream response before its applicable timeout. Neither code, by itself, tells you which component sent it: the application, nginx, an AWS Application Load Balancer (ALB), or Cloudflare may generate a response, while a later hop may simply forward it.

To find the cause, identify the emitting hop and correlate the same request across the path. Response branding and headers are clues; logs, status fields, timings, and target health are how you verify them.

As an Amazon Associate I earn from qualifying purchases.

What the two status codes mean—and what they do not prove

Status What it generally signals What the code alone cannot tell you
503 Service Unavailable A service is temporarily unable to handle the request, commonly because it is overloaded or lacks ready targets. Whether the application, proxy, load balancer, or edge service generated the response—or whether a later layer forwarded it.
504 Gateway Timeout A gateway or proxy did not get an upstream response within the timeout that applied to that phase. Which hop timed out, whether the cause was application response time, connection setup, network policy, or another failure.
502 Bad Gateway A gateway received an invalid response or had a failed interaction with an upstream. Which component produced it; it is useful context when distinguishing an invalid upstream response from a timeout.

These are general signals, not a complete diagnosis. An edge service can pass along an origin’s status, and an intermediary can instead synthesize its own error. Start by finding which hop’s status matches the response seen by the client.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What triggers 503 and 504 at each layer

nginx: separate upstream phases, not one universal timeout

nginx’s proxy module documentation defines separate timeouts for connecting to an upstream, sending the request, and reading the response. The documented defaults for proxy_connect_timeout, proxy_send_timeout, and proxy_read_timeout are each 60s; the effective values depend on the active configuration.

A key distinction: proxy_read_timeout measures the interval between successive read operations from the upstream, not a deadline for the entire response. A response can take longer than that value overall if data continues to arrive within each interval. A 504 therefore needs to be matched to the relevant phase and configured timeout, not just to the total duration of a request.

nginx can try another upstream under proxy_next_upstream. Its documented default conditions are error timeout; available conditions also include invalid_header and selected upstream HTTP statuses, including 500, 502, 503, and 504. A retry is only possible if nginx has not already sent response data to the client. Whether a retry happens depends on the active directives, upstream pool, request method, and response state; a retry cannot undo a response that has begun streaming.

AWS ALB: 503 often concerns ready targets; 504 has several possible phases

AWS lists ALB-generated 503 causes including a target group with no registered targets, all registered targets being in an unused state, or target optimizer having no targets ready for a routed request. AWS states: “Consistent HTTP 503 errors means that there are insufficient targets ready to receive requests from the ALB.” This is AWS’s troubleshooting guidance, not proof that every ALB 503 has that cause.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

AWS documents several possible ALB 504 causes. They include failure to establish a target connection before the 10-second connection timeout, a connected target not responding before the ALB idle timeout, network ACL rules blocking relevant ephemeral-port traffic, and a response whose Content-Length exceeds its entity body. Certain Lambda or TLS handshake timeouts are also listed. These point to different failure phases: connection setup, waiting on a response, network access, response framing, or integration/handshake behavior—not simply an application that is “slow.”

For attribution, compare the ALB access-log record’s load-balancer status with the target status, and inspect target-group health. AWS exposes separate HTTPCode_ELB_* and HTTPCode_Target_* metrics, which help distinguish a response generated by the load balancer from one returned by a target. See AWS’s ALB troubleshooting guide.

Cloudflare: response body and branding offer clues, not certainty

Cloudflare distinguishes errors generated at its edge from errors returned by an origin. Its 502/504 guidance says Cloudflare may display a branded error when the origin returns a standard 502 or 504. A blank or unbranded 502/504 can indicate a Cloudflare-generated error, but appearance alone is not conclusive: customized error pages or another proxy can obscure the source.

For 503s, Cloudflare says an HTML response body containing cloudflare or cloudflare-nginx points toward a Cloudflare-generated response; without those markers, the origin is the likely source. On the origin side, Cloudflare lists overload, rate limiting, connection pools, and maintenance mode as checks. On the Cloudflare side, it identifies data-center connectivity problems; Workers deployments should also be checked for CPU or memory limit errors. Its 502/504 guidance includes origin overload, crashes, network failures, and timed-out or blocked application services. The Cloudflare 503 guide and 502/504 guide give the relevant checks.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How to tell whether the response came from Cloudflare, a load balancer, or the origin

  1. Capture the response as seen by the client. Record the exact status, full body, relevant headers, URL, and occurrence time with timezone. For a Cloudflare response, record the Ray ID if available.
  2. Use the response as a lead, not a verdict. Note branding and body markers that suggest Cloudflare, nginx, ALB, or the application, then verify against the logs. Customized pages and intermediary proxies can make appearance misleading.
  3. Trace the request hop by hop. Compare the client-facing status with nginx upstream status and timing, ALB load-balancer status versus target status and target-group health, and Cloudflare edge versus origin status where available. Include intervening caches, proxies, and firewalls.
  4. Separate timing phases. Check connection-establishment time, time waiting for the first response bytes, gaps between response reads, and total request time independently. Compare each with the timeout configured at the hop that performed that operation.
  5. For a 503, check readiness and capacity. Inspect target registration and health, application worker or connection-pool exhaustion, rate limiting, maintenance mode, and overload.
  6. For a 502 or 504, check transport and response validity. Look for resets, failed connections, TLS handshake problems, invalid or empty upstream headers, content-length mismatches, blocked network paths, and relevant intermediary logs.
  7. Change timeout or retry settings only after locating the failing hop. A longer timeout can conceal saturation or hold resources longer; retries of non-idempotent requests can have side effects. For nginx, retry eligibility also depends on whether response data has already reached the client.

What to check when origin logs do not explain a Cloudflare error

A missing event in origin logs does not establish that the origin was healthy: the request may have failed at an intermediary or before reaching the origin. Cloudflare advises checking logs from load balancers, caches, proxies, and firewalls between its edge and the origin. Its Error Analytics are based on a 1% traffic sample, according to Cloudflare’s 5xx guidance; that describes the analytics sample, not the site’s error rate or a general sampling property of nginx or ALB.

If escalating a Cloudflare issue, provide the status, exact timestamp and timezone, URL, and diagnostic details Cloudflare requests; its guidance also mentions /cdn-cgi/trace. For an ALB issue, align load-balancer and target metrics with the access-log record for the request. No single dashboard is guaranteed to show the root cause, so follow the evidence across the path.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.