highIntermediateRED#lambda#timeout#serverless#duration

Lambda function timing out — exceeded configured timeout

CloudWatch log line: 'Task timed out after X seconds'

Likely source:performanceconfiguration

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'
READ

Current budget

Fix

aws lambda update-function-configuration --function-name <FUNCTION> --timeout <NEW-SECONDS>
CHANGE

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.

1
aws logs filter-log-events --log-group-name /aws/lambda/<FUNCTION> --filter-pattern "Task timed out"
READ

Baseline: how often and how long

2
aws lambda get-function-configuration --function-name <FUNCTION> --query '{Timeout:Timeout,Memory:MemorySize}'
READ

Current limits

3
aws lambda update-function-configuration --function-name <FUNCTION> --timeout <NEW-SECONDS>
CHANGE

Lift the timeout to match real work

4
aws logs tail --log-group-name /aws/lambda/<FUNCTION> --since 10m --follow
READ

Watch 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.

Commands marked READ CHANGE DESTRUCTIVE — never run DESTRUCTIVE commands against production data you cannot restore. Copy → verify → execute.