← Back to all fixes
AWS

Lambda function times out

The Issue

Lambda function returns: `Task timed out after 3.00 seconds`

Root Cause

Default Lambda timeout is 3 seconds. If your function does DB queries, calls external APIs, or processes large files, it exceeds this limit.

How to Fix
  1. Increase timeout in Lambda console (Configuration > General configuration) — max is 15 minutes
  2. Profile what is slow inside the function — add timestamps around each operation
  3. Move heavy processing to a background job (SQS + Lambda consumer) instead of synchronous
  4. For very long tasks: use Step Functions or ECS Fargate instead of Lambda
  5. Set timeout to expected duration + 20% buffer, not the maximum