Free auditStart free
GuideError · CDN and hosting errors

API Gateway 504 Gateway Timeout

Why Amazon API Gateway returns a 504: the integration timeout limits for REST and HTTP APIs, how to confirm it in the logs, and how to fix a slow Lambda or backend.

4 min
read
9
sources
Oct 29, 2026
updated
Scaplet Editorial Team
author
In one line

A 504 from Amazon API Gateway means the backend integration did not answer within the integration timeout. For REST APIs the limit is 50 milliseconds to 29 seconds by default, and HTTP APIs top out at 30 seconds. Confirm the gateway response type in CloudWatch, then speed up the backend, raise the Lambda timeout only below the API limit, or make the work asynchronous.

30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
01Gateway responses that return 504 (REST APIs)

What a 504 from API Gateway means

API Gateway sits between the client and your integration (a Lambda function, an HTTP backend or another AWS service). RFC 9110 defines a 504 as the status for a server that, "while acting as a gateway or proxy, did not receive a timely response from an upstream server". API Gateway applies that to its own integration timeout.
Gateway response type

INTEGRATION_TIMEOUT

Default status
504
What AWS says it is
The gateway response for an integration timed out error
Gateway response type

INTEGRATION_FAILURE

Default status
504
What AWS says it is
The gateway response for an integration failed error

Both types fall back to DEFAULT_5XX if you have not customized them. The same table lists REQUEST_TOO_LARGE (413), THROTTLED (429) and API_CONFIGURATION_ERROR (500), so check the type before you assume a timeout.

03How it works

Confirm it is a timeout

Time the call and read the status
curl -s -o /dev/null -w "status=%{http_code} total=%{time_total}s\n" \
  "https://abc123.execute-api.us-west-2.amazonaws.com/prod/report"
  1. 01

    Reproduce with the invoke URL

    REST API URLs have the form https://api-id.execute-api.region.amazonaws.com/stage/. Call the failing route with curl -s -o /dev/null -w "%{http_code} %{time_total}s\n" https://api-id.execute-api.us-west-2.amazonaws.com/prod/getUsers. A 504 that arrives close to the integration timeout points to the timeout, not a crash.

  2. 02

    Turn on execution logging

    For REST APIs, API Gateway has execution logging (errors and execution traces) and access logging. Enabling CloudWatch Logs needs the AmazonAPIGatewayPushToCloudWatchLogs managed policy on a role set as cloudWatchRoleArn on your account, once per Region.

  3. 03

    Compare latency metrics

    The REST API metrics doc suggests watching IntegrationLatency for backend responsiveness and Latency for the whole call. Near-limit IntegrationLatency values confirm the backend is the slow part.

  4. 04

    Check the backend on its own

    Time the Lambda or HTTP endpoint without the gateway. If it runs longer than the API limit, no gateway setting will fix it.

04Which fix fits

Fixes by cause

Cause

Backend is slow because of a downstream call

Fix
Add timeouts and caching in the function; time each call
Cause

Lambda timeout lower than needed (default 3 seconds)

Fix
Raise it, staying under the API limit
Cause

Work takes longer than 29 or 30 seconds

Fix
Return 202 quickly and finish the job asynchronously; poll or notify
Cause

Regional or private REST API needs more than 29 seconds

Fix
Request a higher integration timeout, accepting the throttle quota trade-off AWS describes
Raise the Lambda timeout (seconds)
aws lambda update-function-configuration \
  --function-name my-function \
  --timeout 25
Raise the timeout when
  • The work is bounded and close to the limit
  • You can stay under 29 seconds for edge-optimized APIs
  • You accept the throttle quota trade-off on Regional or private APIs
Go asynchronous when
  • The job can take longer than the API limit
  • Clients can poll or receive a callback
  • You need the request to finish even if the client disconnects
05Explained

What it means for SEO and crawlers

An API behind a page can break the page. If Googlebot fetches a URL whose HTML depends on a call that returns 504, Google treats it as a server error: it says 5xx and 429 errors "prompt Google's crawlers to temporarily slow down with crawling", and already indexed URLs "are preserved in the index, but eventually dropped" if the errors persist. Keep pages that must be indexed from depending on a slow API call at request time. For the general meaning see 504 Gateway Timeout.
Questions

Asked a lot.

3 questions people ask next, answered from the sources on this page.

01Why does API Gateway return 504 after 29 seconds?

The default integration timeout for REST APIs is 50 milliseconds to 29 seconds for all integration types. When the Lambda function or HTTP backend does not respond within it, API Gateway returns an integration timeout response with status 504.

02Can I raise the API Gateway timeout above 29 seconds?

Not for edge-optimized REST APIs. For Regional and private REST APIs AWS says you can, but it might require reducing your Region-level throttle quota. HTTP APIs have a fixed 30 second maximum.

03What is the difference between INTEGRATION_FAILURE and INTEGRATION_TIMEOUT?

Both default to 504. AWS describes the first as an integration failed error and the second as an integration timed out error, so read the gateway response type in the logs to tell them apart.

Sources · 9

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • rfc-editor.org
  • amazon.com
  • google.com
  1. 01RFC 9110: HTTP Semanticsrfc-editor.org · checked 2026-11-01
  2. 02Quotas for configuring and running a REST API in API Gatewaydocs.aws.amazon.com · checked 2026-11-01
  3. 03Quotas for configuring and running an HTTP API in API Gatewaydocs.aws.amazon.com · checked 2026-11-01
  4. 04Gateway response types for API Gatewaydocs.aws.amazon.com · checked 2026-11-01
  5. 05Set up CloudWatch logging for REST APIs in API Gatewaydocs.aws.amazon.com · checked 2026-11-01
  6. 06Monitor REST API execution with Amazon CloudWatch metricsdocs.aws.amazon.com · checked 2026-11-01
  7. 07Invoke REST APIs in API Gatewaydocs.aws.amazon.com · checked 2026-11-01
  8. 08Configure Lambda function timeoutdocs.aws.amazon.com · checked 2026-11-01
  9. 09How HTTP status codes affect Google's crawlersdevelopers.google.com · checked 2026-11-01
Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane