# API Gateway: {"message": "Endpoint request timed out"} (504 after 29 seconds)

**Code:** `Endpoint request timed out` · **Category:** AWS · **Seen on:** AWS

The backend (usually Lambda) didn’t respond within API Gateway’s integration timeout (29 seconds by default for REST APIs).

## Meaning

Even if the Lambda timeout is 15 minutes, the API returns 504 at the integration limit. Long-running work must go async (queue + polling/webhook), or be sped up.

## Common causes

- Lambda/backend work takes longer than the integration timeout
- Cold start + slow dependency (DB in VPC, external API)
- Lambda in a VPC without NAT waiting on internet calls

## Quick fix

1. Move long tasks to async processing (SQS/Step Functions) and return 202
2. Optimise the slow call; add timeouts on outbound requests
3. Request a higher integration timeout where supported

## Detailed fix by platform

### AWS CLI

1. `aws logs tail /aws/lambda/my-fn --since 10m | grep -E 'REPORT|Task timed out'`

## How to diagnose

1. **Duration** — Lambda REPORT duration
2. **Dependencies** — Slow outbound calls?
3. **VPC** — NAT for internet access?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/aws/apigateway-endpoint-request-timed-out)
