# 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.

Canonical: https://scaplet.com/errors/cdn/api-gateway-504

Guide Error · CDN and hosting errors

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 with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Fapi-gateway-504%20(%22API%20Gateway%20504%20Gateway%20Timeout%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Fapi-gateway-504%20(%22API%20Gateway%20504%20Gateway%20Timeout%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Fapi-gateway-504%20(%22API%20Gateway%20504%20Gateway%20Timeout%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Ferrors%2Fcdn%2Fapi-gateway-504%20(%22API%20Gateway%20504%20Gateway%20Timeout%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

On this page

## 5 parts, 4 minutes.

1. [What a 504 from API Gateway means 01](#what-a-504-from-api-gateway-means)
2. [The timeout limits that cause it 02](#the-timeout-limits-that-cause-it)
3. [Confirm it is a timeout 03](#confirm-it-is-a-timeout)
4. [Fixes by cause 04](#fixes-by-cause)
5. [What it means for SEO and crawlers 05](#what-it-means-for-seo-and-crawlers)

_01_Gateway 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.

_02_Documented integration limits

## The timeout limits that cause it

API type

### REST API, Regional

Integration timeout

50 milliseconds to 29 seconds, all integration types

Can it be raised?

Yes, with a quota request

API type

### REST API, edge-optimized

Integration timeout

50 milliseconds to 29 seconds, all integration types

Can it be raised?

No

API type

### REST API, private

Integration timeout

50 milliseconds to 29 seconds, all integration types

Can it be raised?

Yes, with a quota request

API type

### HTTP API

Integration timeout

Maximum integration timeout 30 seconds

Can it be raised?

No

AWS adds a caveat for the raisable REST cases: you can raise the integration timeout above 29 seconds, but this "might require a reduction in your Region-level throttle quota for your account". The Lambda side has its own limit: the function timeout defaults to 3 seconds and can be set up to 900 seconds. A Lambda set to 60 seconds behind a 29 second API still returns a 504 to the client when the function runs longer than 29 seconds.

**Two timers, the smaller one wins**Compare the [Lambda timeout](/errors/cdn/lambda-timeout), the integration timeout on the method and the API limit. The request fails at whichever is shortest, and the client sees a 504 even if the function keeps running to completion in the background.

_03_How 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.

_04_Which 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

_05_Explained

## What it means for SEO and crawlers

An API behind a page can break the page. If [Googlebot](/ai-crawlers/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](/errors/http/504).

Questions

## Asked a lot.

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

_01_ Why 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.

_02_ Can 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.

_03_ What 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. 01 [RFC 9110: HTTP Semantics](https://www.rfc-editor.org/rfc/rfc9110.html) rfc-editor.org · checked 2026-11-01
2. 02 [Quotas for configuring and running a REST API in API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-execution-service-limits-table.html) docs.aws.amazon.com · checked 2026-11-01
3. 03 [Quotas for configuring and running an HTTP API in API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-quotas.html) docs.aws.amazon.com · checked 2026-11-01
4. 04 [Gateway response types for API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/supported-gateway-response-types.html) docs.aws.amazon.com · checked 2026-11-01
5. 05 [Set up CloudWatch logging for REST APIs in API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-logging.html) docs.aws.amazon.com · checked 2026-11-01
6. 06 [Monitor REST API execution with Amazon CloudWatch metrics](https://docs.aws.amazon.com/apigateway/latest/developerguide/monitoring-cloudwatch.html) docs.aws.amazon.com · checked 2026-11-01
7. 07 [Invoke REST APIs in API Gateway](https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-call-api.html) docs.aws.amazon.com · checked 2026-11-01
8. 08 [Configure Lambda function timeout](https://docs.aws.amazon.com/lambda/latest/dg/configuration-timeout.html) docs.aws.amazon.com · checked 2026-11-01
9. 09 [How HTTP status codes affect Google's crawlers](https://developers.google.com/crawling/docs/troubleshooting/http-status-codes) developers.google.com · checked 2026-11-01

## Keep learning

[All errors](/errors)

[Learn AWS 502 Bad Gateway CDN and hosting errors](/errors/cdn/aws-502-bad-gateway) [Related 504 Gateway Timeout HTTP status codes](/errors/http/504) [Read next ALB 504 Gateway Timeout CDN and hosting errors](/errors/cdn/alb-504-gateway-timeout) [Do Run a free site audit Free, about two minutes](/site-audit)

Other 504 errors
[504 Gateway Timeout in Apache](/errors/http/504/apache) [504 Gateway Timeout on IIS](/errors/http/504/iis) [ALB 504 Gateway Timeout](/errors/cdn/alb-504-gateway-timeout) [Cloudflare 504 Gateway Timeout](/errors/cdn/cloudflare-504) [504 Gateway Time-out in nginx](/errors/http/504/nginx)

More Api errors
[API Gateway 403 Forbidden](/errors/cdn/api-gateway-403-forbidden)

More in CDN and hosting errors
[S3 Access Denied (403 Forbidden)](/errors/cdn/s3-access-denied) [Vercel 413: FUNCTION_PAYLOAD_TOO_LARGE](/errors/cdn/vercel-payload-too-large) [Vercel 429: Too Many Requests](/errors/cdn/vercel-429) [Vercel 500: Internal Server Error](/errors/cdn/vercel-500) [Vercel build failed](/errors/cdn/vercel-build-failed) [Vercel domain not working](/errors/cdn/vercel-domain-not-working) [Vercel FUNCTION_INVOCATION_TIMEOUT](/errors/cdn/vercel-function-invocation-timeout) [Vercel: too many redirects](/errors/cdn/vercel-too-many-redirects) [Akamai reference number](/errors/cdn/akamai-reference-number) [ALB 503 Service Unavailable](/errors/cdn/alb-503) [ALB 504 Gateway Timeout](/errors/cdn/alb-504-gateway-timeout) [API Gateway 403 Forbidden](/errors/cdn/api-gateway-403-forbidden) [API Gateway 504 Gateway Timeout](/errors/cdn/api-gateway-504) [AWS 502 Bad Gateway](/errors/cdn/aws-502-bad-gateway) [AWS Amplify 404 Not Found](/errors/cdn/amplify-404) [AWS EC2: Connection timed out](/errors/cdn/aws-ec2-connection-timed-out) [AWS Lambda 502 Bad Gateway](/errors/cdn/aws-lambda-502) [AWS Lambda timeout](/errors/cdn/lambda-timeout) [Azure Front Door 502](/errors/cdn/azure-front-door-502) [Cloud Run 503 error](/errors/cdn/cloud-run-503) [Cloudflare 504 Gateway Timeout](/errors/cdn/cloudflare-504) [Cloudflare Pages 404 Not Found](/errors/cdn/cloudflare-pages-404) [Cloudflare too many redirects (ERR_TOO_MANY_REDIRECTS)](/errors/cdn/cloudflare-too-many-redirects) [Cloudflare verify you are human loop](/errors/cdn/cloudflare-verify-you-are-human-loop)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

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

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
