← Back to all fixes
ALB returns 504 Gateway Timeout
The Issue
Some requests hitting the ALB return 504 after 60 seconds.
Root Cause
ALB idle timeout (default 60s) is shorter than your app's response time. ALB closes the connection before the backend finishes.
How to Fix
Increase ALB idle timeout: EC2 console > Load Balancers > your ALB > Attributes > Idle timeoutSet it slightly above your slowest expected response timeAlso check if your target group health check is failing — unhealthy targets get 502/504Profile your app to reduce response time for slow endpointsFor very long operations: return 202 Accepted immediately and process asynchronously