What HTTP 504 means
RFC 9110 §15.6.5. The proxy got tired of waiting for your app. Different from 502 (which is connection-level). Tune both proxy timeouts (nginx proxy_read_timeout, ALB idle timeout) and upstream response time.
Typical causes
- Slow upstream response
- Long-running query
- Database lock contention
- Proxy timeout too aggressive