Lambda function timing out — exceeded configured timeout
CloudWatch log line: 'Task timed out after X seconds'
Focused incident mode — strips away everything but this runbook.
Symptoms
- CloudWatch log line: 'Task timed out after X seconds'
- Function duration at the configured timeout for many invocations
- Clients see gateway/API timeout errors from Lambda-backed APIs
Raising the timeout only buys time — the ceiling is 900 seconds. Timeouts that repeat after the raise are an app bug; timeouts with a known slow external call are a case for async + SQS instead of a bigger wait.
Evidence to grab
Collect these artifacts before you change anything — they prove (or rule out) each cause.
Log evidence
aws logs filter-log-events --log-group-name /aws/lambda/<FUNCTION> --filter-pattern 'Task timed out'Function configuration
aws lambda get-function-configuration --function-name <FUNCTION> --query '{Timeout:Timeout,Memory:MemorySize,Role:Role}'
Diagnostic flow
Run the steps in order, marking each claim confirmed or refuted. The evidence you gather feeds the ranked causes below.
Guided decision tree is ready.
Steps with commands, expected output, and pass/fail branches.
Ranked root causes
Evidence checklist
- Logs show the timeout after a long call to a DB or API
- X-Ray shows one segment at the timeout boundary
Confirm before fixing
aws lambda get-function-configuration --function-name <FUNCTION> --query 'Timeout'Current budget
Fix
aws lambda update-function-configuration --function-name <FUNCTION> --timeout <NEW-SECONDS>Raise the timeout to cover the dependency (if it can complete) — or add retry/backoff logic instead
Resolution runbook
Apply from top to bottom after the cause is confirmed. Review every command before running it — risk tags are shown on each.
aws logs filter-log-events --log-group-name /aws/lambda/<FUNCTION> --filter-pattern "Task timed out"Baseline: how often and how long
aws lambda get-function-configuration --function-name <FUNCTION> --query '{Timeout:Timeout,Memory:MemorySize}'Current limits
aws lambda update-function-configuration --function-name <FUNCTION> --timeout <NEW-SECONDS>Lift the timeout to match real work
aws logs tail --log-group-name /aws/lambda/<FUNCTION> --since 10m --followWatch the function recover in logs
Prevention
- Set Lambda timeouts as a contract, and alarm on Duration nearing it.
- Use X-Ray to segment cold start, downstream calls, and compute.
- Push long-running work to Step Functions or SQS consumers instead of inflating timeouts.
Related runbooks
Same stack, same failure family — worth a skim.
Invoke returns 403 'The provided execution role does not have permissions'
Each poisoned event processed twice (synchronous + async retry)
Commands marked READ CHANGE DESTRUCTIVE — never run DESTRUCTIVE commands against production data you cannot restore. Copy → verify → execute.