What AWS Lambda's 'Task timed out' log line means, the 3-second default and 1,800-second maximum, the callers with shorter deadlines, and the causes that a higher timeout does not fix.

Task timed out after 3.00 seconds means Lambda stopped your function because it ran past its configured timeout, which is 3 seconds unless someone changed it. The number in the message is that setting, not how long the work needed.
Raising it fixes the case where the work is slower than the default. For a function stuck on a network call, it only makes the failure take longer.
Lambda gives every invocation a deadline equal to the function's timeout, and when it passes, the runtime is stopped mid-execution and the log gets a Task timed out line before the usual REPORT line. Per the timeout docs, the default is 3 seconds and the maximum is 1,800 seconds, or 5,400 for asynchronous and event source mapping invocations on Lambda Managed Instances. Whatever the function was doing is lost, and the caller retries or not depending on how it was invoked.
aws lambda update-function-configuration \
--function-name resize-image \
--timeout 60
In AWS SAM it is Timeout: 60 on the function, in Terraform timeout = 60 on aws_lambda_function, and in CDK timeout: Duration.seconds(60). Set it from measured duration with headroom, since a timeout close to the average fails on every slow invocation.
The API Gateway values are from the REST API quotas and HTTP API quotas, checked on November 20, 2026. If the caller gives up first, the user sees a 504 while the function runs on, and raising the Lambda timeout past the caller's limit does nothing for them.
For SQS, the event source docs ask for a visibility timeout of at least six times the function timeout. With a shorter one, a message becomes visible again while the first invocation is still running and a second one processes it too.
Log the remaining budget at each step with context.getRemainingTimeInMillis(), and wrap outbound calls with explicit timeouts:
// handler.ts (Node.js 22 runtime)
import type { Context } from "aws-lambda";
export const handler = async (event: { url: string }, context: Context) => {
console.log("start", context.getRemainingTimeInMillis());
// Fail at 5 s with a clear error instead of hanging until the function times out.
const res = await fetch(event.url, { signal: AbortSignal.timeout(5_000) });
console.log("fetched", res.status, context.getRemainingTimeInMillis());
return { status: res.status };
};
AWS X-Ray tracing on the function shows the same breakdown per downstream call without the log lines.
Encore is a backend framework with built-in infrastructure, and on AWS your services run as long-lived containers on Fargate in your own account, per the AWS infrastructure docs. There is no per-invocation timeout to configure, and long work goes to Pub/Sub subscriptions, which Encore provisions as SNS topics with SQS queues and dead-letter queues, with the subscription's ack deadline set in code.

Run in your terminal to get started locally.
An image resize that used to run in an API Gateway-backed Lambda, split into an endpoint that answers right away and a subscriber that does the work:
// images/images.go
package images
import (
"bytes"
"context"
"time"
"encore.dev/pubsub"
"encore.dev/storage/objects"
)
var originals = objects.NewBucket("originals", objects.BucketConfig{})
var thumbnails = objects.NewBucket("thumbnails", objects.BucketConfig{})
type ResizeRequested struct {
Key string
}
var resizes = pubsub.NewTopic[*ResizeRequested]("resize-requested", pubsub.TopicConfig{
DeliveryGuarantee: pubsub.AtLeastOnce,
})
type ResizeParams struct {
Key string
}
type ResizeResponse struct {
Queued bool
}
//encore:api public method=POST path=/images/resize
func Resize(ctx context.Context, p *ResizeParams) (*ResizeResponse, error) {
if _, err := resizes.Publish(ctx, &ResizeRequested{Key: p.Key}); err != nil {
return nil, err
}
return &ResizeResponse{Queued: true}, nil
}
var _ = pubsub.NewSubscription(resizes, "make-thumbnail", pubsub.SubscriptionConfig[*ResizeRequested]{
Handler: makeThumbnail,
AckDeadline: 5 * time.Minute,
RetryPolicy: &pubsub.RetryPolicy{MaxRetries: 5},
})
func makeThumbnail(ctx context.Context, msg *ResizeRequested) error {
r := originals.Download(ctx, msg.Key)
defer r.Close()
var src bytes.Buffer
if _, err := src.ReadFrom(r); err != nil {
return err
}
out := thumbnail(src.Bytes())
// Same key on a retry, so a redelivered message overwrites the earlier result.
w := thumbnails.Upload(ctx, msg.Key)
if _, err := w.Write(out); err != nil {
w.Abort(err)
return err
}
return w.Close()
}
// thumbnail stands in for your image library of choice.
func thumbnail(src []byte) []byte { return src }
The buckets become S3 buckets in your account, as the object storage docs describe. Locally, encore run runs the topic and buckets for the same code, so the flow is testable without deploying.
A coding agent fixing a timeout like this one can move the work into a subscription in the same change, run it locally and open a pull request, with no queue, event source mapping or IAM policy to set up by hand.
Best fit: Teams on AWS whose functions keep hitting timeouts and who want long work in queue consumers they declare in code.
Duration in the REPORT lines of successful runs with the configured timeout.The default is 3 seconds, and you can raise it in 1-second steps up to 1,800 seconds (30 minutes), and functions on Lambda Managed Instances allow up to 5,400 seconds for asynchronous and event source mapping invocations.
A function attached to a VPC has no internet access unless its subnets route through a NAT gateway, so calls to public APIs, including some AWS service endpoints, hang until the function times out. Add a NAT gateway or VPC endpoints for the AWS services it calls.
No. API Gateway REST APIs stop waiting at 29 seconds by default and HTTP APIs at 30 seconds, so a longer function timeout only means the function keeps running after the client already got a 504.
Add timeouts to every outbound call so the slow one fails with its own error, and log the remaining time from context.getRemainingTimeInMillis() at each step. AWS X-Ray tracing shows the time spent in each downstream call.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.