Task timed out after 15.00 seconds

Lambda timeout at 15 seconds even after setting higher timeout

Server & Cloud Intermediate 👁 7 views 📅 Jun 21, 2026

Your Lambda function times out at 15 seconds no matter what you set in the console. The issue is usually VPC setup or a hidden default in the execution role.

Start with the simple fix (30 seconds)

First thing — check if you're actually changing the timeout in the right place. I had a client last month who was editing the function code but not the configuration tab. The timeout setting lives in Configuration → General configuration → Edit. Make sure you set it to something like 30 seconds and hit Save.

Then test it. If it still times out at 15 seconds exactly, the problem isn't the number you set. The function is hitting the default execution role timeout or a VPC issue.

Check the execution role's maximum session duration

Go to IAM → Roles → Find your Lambda's role. Look at the Maximum session duration — it's often set to 1 hour by default, but sometimes a policy or trust relationship limits it. If you see a value like 900 seconds (15 minutes), that's your problem. Edit the role and change it to 3600 seconds (1 hour) or whatever you need.

Moderate fix: VPC setup (5 minutes)

If your Lambda function is attached to a VPC, this is the most common reason for the 15-second timeout. Here's why: Lambda needs internet access to reach things like DynamoDB, S3, or external APIs. Without a NAT gateway or VPC endpoint, it can't talk to anything outside the VPC. The function starts, tries to connect, and hangs for 15 seconds before Lambda kills it.

  1. Go to your function's Configuration → VPC tab.
  2. If it's attached to a VPC, note the subnets and security groups.
  3. Make sure your subnets have a route to a NAT gateway in a public subnet. Without that, Lambda has no internet access.
  4. Check your security group — it needs an outbound rule to allow traffic to 0.0.0.0/0 on HTTPS (port 443) and HTTP (port 80).
  5. If you don't need internet access, use VPC endpoints for the services you need (like S3, DynamoDB).

Here's a quick test: remove the VPC attachment entirely and run the function. If it finishes in under a second, the VPC setup is the culprit. Add the VPC back but fix the routing.

Real example from my work

Had a client whose Lambda processed images from S3. It took 2 seconds without a VPC, but 15 seconds with one. Turned out the security group only allowed inbound traffic, no outbound. Took me 30 seconds to spot. Added an outbound rule for 0.0.0.0/0 on HTTPS, and the function ran fine.

Advanced fix: Permissions, concurrency, and code issues (15+ minutes)

If the simple and moderate fixes don't work, something deeper is wrong. Let's check three things:

1. Execution role permissions

Lambda needs permissions to log to CloudWatch. Without it, the function can start but can't write logs, which can cause delays. Add this policy to your role:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "logs:CreateLogGroup",
        "logs:CreateLogStream",
        "logs:PutLogEvents"
      ],
      "Resource": "arn:aws:logs:*:*:*"
    }
  ]
}

2. Reserved concurrency

If you set reserved concurrency to a low number (like 5), Lambda might queue your invocation. Check Configuration → Concurrency. Set it to Use unreserved account concurrency or set a number high enough for your workload. Low concurrency can cause timeouts that look like the 15-second limit.

3. Code that's actually stuck

Sometimes the code itself has an infinite loop or a slow query. Add some logging at the very start of your handler:

exports.handler = async (event) => {
  console.log('Function started at', new Date().toISOString());
  // your code here
  console.log('Function ended at', new Date().toISOString());
};

Run the function and check CloudWatch logs. If the start log shows up but the end log doesn't, the code is hanging. Look for synchronous HTTP requests, large database queries, or recursive calls.

4. Lambda execution environment limits

Lambda has a hard limit of 15 minutes (900 seconds) for synchronous invocations and 15 minutes for asynchronous ones. If you're hitting exactly 15 seconds, it's not that limit — it's something else. But if you need more than 15 minutes, you can't use Lambda. Switch to AWS Batch or ECS.

Quick tip: If you're using Node.js, check for missing await on async calls. That's a common one I see — the function returns early but the promise never resolves, causing a timeout.

When all else fails

If you've tried everything and it still times out at 15 seconds, create a new Lambda function from scratch with the same code but no VPC. If that works, the issue is your VPC setup (security group, NACL, or routing). If not, it's a permissions or code issue. I've had to rebuild a function twice because an IAM policy had a typo in the resource ARN — cost me an hour.

One more thing: if you're using CloudFront or API Gateway in front of Lambda, those services have their own timeouts. API Gateway times out at 29 seconds. But if you're seeing Lambda itself timeout at 15 seconds, it's not the gateway. Check the Lambda logs.

Was this solution helpful?