Task timed out AWS Origin: Platform & cloud Last updated 14 Oct 2026

AWS Lambda: Task timed out after X seconds

The function ran longer than its configured timeout (default 3 seconds) and Lambda stopped it.

Exact message you may see Task timed out afterLambda timeout
Seen on: AWS Node.js Python

Meaning

Lambda’s default timeout is only 3 seconds. Beyond slow code, the classic causes are network calls that hang (Lambda in a VPC without a NAT gateway can’t reach the internet), cold starts, and open DB connections keeping the event loop alive in Node.

Common causes

  • Default 3s timeout too low
  • Lambda in a VPC calling the internet without NAT / VPC endpoints
  • Slow downstream API or database
  • Node.js event loop kept alive by open connections (callbackWaitsForEmptyEventLoop)
  • Cold start + heavy initialisation

⚡ Quick fix

  1. Raise the timeout (up to 15 min) to a realistic value
  2. Add NAT gateway or VPC endpoints for VPC Lambdas
  3. Set client timeouts shorter than the Lambda timeout
  4. Node: context.callbackWaitsForEmptyEventLoop = false for pooled DB connections

Detailed fix by platform

AWS

  1. Update timeout and memory (more memory = more CPU):
    bash
    aws lambda update-function-configuration --function-name orders-api --timeout 30 --memory-size 512

How to diagnose

  1. Duration — CloudWatch REPORT line: Duration vs timeout
  2. Network — In a VPC? NAT/endpoints?
  3. Downstream — X-Ray: which call is slow?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

2013 — MySQL ERROR 2013 (HY000): Lost connection to MySQL server during query (MySQL)2013504 — HTTP 504 Gateway Timeout (HTTP)50457014 — ERROR: canceling statement due to statement timeout (PostgreSQL)57014cURL error 28 — cURL error 28: Operation timed out after 30001 milliseconds with 0 bytes received (PHP)cURL error 28DEADLINE_EXCEEDED — gRPC Error: 4 DEADLINE_EXCEEDED: Deadline exceeded (API)DEADLINE_EXCEEDEDEndpoint request timed out — API Gateway: {"message": "Endpoint request timed out"} (504 after 29 seconds) (AWS)Endpoint request time…ETIMEDOUT — API Request Timed Out (ETIMEDOUT / ReadTimeout / timeout of 30000ms exceeded) (API)ETIMEDOUTHttpClient.Timeout — TaskCanceledException: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing (.NET)HttpClient.TimeoutTask time…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.