Is every CloudFront 504 caused by slow code?
No. Origin routing, connection establishment, packet loss, and overload can also prevent a timely response.
AWS CloudFront · HTTP 504
Diagnose CloudFront 504 by separating origin connection delay from slow response generation. Measure origin latency and review connection and response timeout settings.
Origin / Application
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.
Diagnostic report
Error code / name
Fault domain
Origin / ApplicationCloudFront 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.
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.
Client -> CloudFront POP -> Origin connection succeeds -> origin response deadline expires -> Xcurl -sS -I -w 'connect=%{time_connect} starttransfer=%{time_starttransfer} total=%{time_total}\n' --max-time 120 https://example.com/healthcustom_origin_config {
origin_read_timeout = 60
origin_keepalive_timeout = 60
}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 freeNo. Origin routing, connection establishment, packet loss, and overload can also prevent a timely response.
It may only delay failure. First measure origin and dependency latency, then adjust timeouts to match the intended workload.