Home/Tutorials/AWS/Error fix
Error fixAWS · 3 min read · Updated 6 Dec 2026

AWS Lambda "Task Timed Out": Causes and Fixes

Lambda "Task timed out after 3.00 seconds" means the function hit its timeout. Fix slow calls, VPC networking, cold starts and wrong timeout settings.

QUICK ANSWERLambda stops a function when it reaches its timeout (3 seconds by default, 15 minutes at most) and logs "Task timed out after X seconds". Common causes are a timeout that is simply too low, a slow downstream call (database, API), a Lambda in a VPC with no route to the internet or AWS services, cold starts with heavy initialisation, or too little memory (which also means less CPU).

Learn this hands-on: covered in Week 6: Serverless and containers of our 12-week AWS Solutions Architect Associate (SAA-C03) course, with live labs and a trainer to help. See the full syllabus →

AWS Lambda task timed out: causes and fixes
AWS Lambda task timed out: causes and fixes

Read the logs first

REPORT RequestId: 1a2b...  Duration: 3003.12 ms  Billed Duration: 3000 ms
Memory Size: 128 MB  Max Memory Used: 127 MB  Init Duration: 812.45 ms
... Task timed out after 3.00 seconds

Duration equal to the timeout confirms it. Max Memory Used close to Memory Size suggests the function needs more memory. A large Init Duration points to slow start-up code.

Causes and fixes

CauseFix
Default 3-second timeout too lowRaise it to realistic time plus a margin (API Gateway still cuts off at 29 seconds by default)
Lambda in a VPC calls the internet or an AWS APIAdd a NAT gateway route, or VPC endpoints (S3, DynamoDB, Secrets Manager)
Slow database or API callSet client timeouts shorter than the Lambda timeout, add retries, reuse connections, use RDS Proxy
Too little memoryIncrease memory; CPU grows with memory, so the function often gets faster and costs the same
Cold start with heavy initMove clients outside the handler, trim packages, use SnapStart (Java/Python/.NET) or provisioned concurrency
Waiting on an empty event loop (Node.js)Make sure promises are awaited; close open handles

Fix it step by step

  1. Open the CloudWatch log group /aws/lambda/<function> and find the timed-out invocation.
  2. Add simple timing logs around each external call to see which one is slow, or turn on X-Ray tracing.
  3. If the function is in a VPC, check: does it really need to be? If yes, check the subnets route to a NAT gateway or that VPC endpoints exist for the services it calls.
  4. Set the SDK or HTTP client timeout lower than the function timeout so you get a clear error instead of a silent timeout.
  5. Increase memory (for example 128 MB → 512 MB) and compare Duration; use AWS Lambda Power Tuning to find the cheapest setting.
  6. Raise the function timeout only after the real cause is fixed.

When Lambda is the wrong tool

Jobs that take longer than 15 minutes, or that wait on long downloads, fit better in Step Functions (to split the work), ECS Fargate tasks or AWS Batch.

Questions

What is the maximum Lambda timeout?

15 minutes (900 seconds). The default for new functions is 3 seconds.

Why does my Lambda work locally but time out in AWS?

Very often it is VPC networking: inside a VPC the function has no internet access unless the subnet routes through a NAT gateway.