AWS CloudFront · HTTP 504

CloudFront 504: Origin Gateway Timeout

Diagnose CloudFront 504 by separating origin connection delay from slow response generation. Measure origin latency and review connection and response timeout settings.

Origin / Application

Decode a CDN or gateway error

Paste a captured HTTP response or enter a status and headers. Only the status and response headers are sent; common credential headers are filtered first.

Supports raw headers, full HTTP responses, JSON with status/statusCode and headers, cURL -v/-i response output, and HAR exports. HAR selects a server error first. cURL commands are never executed; request headers, response bodies, and common credential headers are excluded.

Diagnostic report

Error code / name

AWS_CLOUDFRONT_504

Fault domain

Origin / Application

Why it happened

CloudFront could not connect to the origin or did not receive the origin response within its configured timeout. Slow application work, overloaded targets, and packet loss are common contributors.

Actionable fixes

  1. Correlate x-amz-cf-id with distribution logs and compare origin connection time with response latency.
  2. Inspect application, database, and dependency traces for work that exceeds the origin response window.
  3. Increase origin timeout only when the longer request is expected and downstream limits are aligned.

Why this error happened

CloudFront could not connect to the origin or did not receive the origin response within its configured timeout. Slow application work, overloaded targets, and packet loss are common contributors.

Actionable fixes

  1. Correlate x-amz-cf-id with distribution logs and compare origin connection time with response latency.
  2. Inspect application, database, and dependency traces for work that exceeds the origin response window.
  3. Increase origin timeout only when the longer request is expected and downstream limits are aligned.

Network failure point

Client -> CloudFront POP -> Origin connection succeeds -> origin response deadline expires -> X

Verify origin directly via CLI

curl -sS -I -w 'connect=%{time_connect} starttransfer=%{time_starttransfer} total=%{time_total}\n' --max-time 120 https://example.com/health

Configuration fix

cloudfront.tfhcl
custom_origin_config {
  origin_read_timeout  = 60
  origin_keepalive_timeout = 60
}

Catch this failure before it becomes an outage

SteadyNode tracks status and time-to-first-byte across regions, making gradual origin latency increases visible before CloudFront begins returning 504 responses.

No credit card required.

Start for free

Frequently asked questions

Is every CloudFront 504 caused by slow code?

No. Origin routing, connection establishment, packet loss, and overload can also prevent a timely response.

Will raising origin_read_timeout solve the root cause?

It may only delay failure. First measure origin and dependency latency, then adjust timeouts to match the intended workload.

Cloudflare

Vercel and Netlify

AWS CloudFront and ALB

Fastly

Heroku and Render

Nginx and Envoy