How do I resolve HTTP 504 (Gateway Timeout) errors from CloudFront?

Last updated: 2019-07-17

My Amazon CloudFront distribution is returning an HTTP 504 (Gateway Timeout) error. How do I resolve this error? 

Resolution

To troubleshoot HTTP 504 errors, check the configurations on your firewall, security groups, and origin server to identify the source of the errors. For detailed troubleshooting instructions, see HTTP 504 Status Code (Gateway Timeout).

If you're receiving HTTP 504 errors from CloudFront, but you can connect directly to the origin, then consider increasing the distribution's origin response timeout. By default, CloudFront allows you to keep the origin connection open for 30 seconds. If your applications need more than 30 seconds to process and return a response, then CloudFront returns an HTTP 504 error.

Note: To optimize performance, the connection time between CloudFront and the origin should be kept as short as possible. Because of this, it's a best practice that you keep the origin response timeout value as low as possible.

Follow these steps to change your distribution's origin response timeout:

  1. Open the CloudFront console, and then select your distribution.
  2. Choose the Origins tab, and then select your origin.
  3. Update the Origin Response Timeout value.
  4. Choose Create.

Note: If you're using persistent connections between CloudFront and the origin, be sure that the origin keep-alive timeout value is equal to or greater than the origin response timeout.


Did this article help you?

Anything we could improve?


Need more help?