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

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 are receiving HTTP 504 errors from CloudFront, but you can connect directly to the origin, then consider increasing the origin response timeout of your distribution. By default, CloudFront allows you to keep the origin connection open for 30 seconds. If your applications need more than 30 seconds to process, 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, so we recommend 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 Amazon CloudFront console and select your distribution.
  2. Choose the Origins view and then select your origin.
  3. Update the Origin Response Timeout value.
  4. Choose Create.

Warning: If you set a keep-alive timeout value for your CloudFront distribution, be sure to update the keep-alive timeout value so that it's equal to or greater than the origin response timeout.

Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2018-05-23