Task timed out after 3.00 seconds

Fix AWS Lambda 3-Second Timeout: Task timed out after 3.00 seconds

Your Lambda function hit its 3-second timeout. We'll fix it by raising the timeout limit or speeding up your code. Here's how.

You're testing a Lambda function in the AWS console, and right at the 3-second mark you see Task timed out after 3.00 seconds. This usually happens when you're processing a file, calling an external API, or running a database query that takes longer than the default timeout. For example, you might be generating a PDF from a large report or connecting to a slow third-party service. The function starts fine, but it just doesn't finish in time.

Why Does This Happen?

Lambda functions have a maximum execution time—a timeout. By default, it's set to 3 seconds. The clock starts when your handler begins and stops when it returns a response or throws an error. If your code runs longer than that, Lambda kills it and returns this error. It's not a crash; it's just the service enforcing the limit.

Two possible reasons: your function genuinely needs more time, or your code is slower than it should be. The quickest fix is to increase the timeout. But if you keep bumping it up and the function still times out, you need to look at your code—maybe a loop is inefficient, or you're waiting on something that's slow.

How to Fix It

Step 1: Open Your Lambda Function

  1. Log in to the AWS Management Console.
  2. Go to Lambda from the services menu.
  3. Click on the name of your function.

You'll land on the function's configuration page. You should see the code and some basic settings.

Step 2: Edit the Timeout Setting

  1. Click the Configuration tab at the top of the function page.
  2. In the left sidebar, click General configuration.
  3. Click the Edit button on the right side.

This opens a form where you can change memory and timeout.

Step 3: Increase the Timeout

  1. In the Timeout field, change it from 3 seconds to something like 10 seconds. You can type a number or use the up/down arrows.
  2. Click Save at the bottom.

After saving, you'll see the new timeout value in the General configuration panel. It should say 0 minutes 10 seconds instead of 0 minutes 3 seconds.

Step 4: Test the Function Again

  1. Click the Test button at the top of the page.
  2. Select an existing test event or create a new one.
  3. Click Invoke.

If your function finishes in under 10 seconds, you'll see a success response. If it still times out, you need to either increase the timeout further (up to 900 seconds, but that's extreme) or optimize your code.

What If It Still Times Out?

If increasing the timeout doesn't help, your function is probably stuck on something—maybe an infinite loop or a call to a resource that never responds. Here's what to check:

Check Your Code for Slow Operations

  • Look for loops that might run too many times. If you're processing a large list, consider breaking it into chunks or using parallel processing.
  • Check if you're making unnecessary API calls. For example, if you call an external service inside a loop, that's a red flag. Move the call outside if possible.
  • Look for any synchronous calls that block. Avoid using await on operations that don't need it, and use Promise.all when you have multiple independent async calls.

Check Your Dependencies

If your function connects to a database or another AWS service, verify those services are responding. A common issue is a database connection pool that's exhausted or a VPN that's down. Check CloudWatch logs for your function to see where it gets stuck.

Look at CloudWatch Logs

  1. Go to CloudWatch in the console.
  2. Click Log groups in the left menu.
  3. Find the log group for your function (it's named /aws/lambda/your-function-name).
  4. Click on the latest log stream and look for the last log entry before the timeout.

That last entry often shows the last line of code that executed. If it's an await on a network call, that's your culprit.

My Opinion on the Real Fix

Increasing the timeout is a band-aid. The real fix is to make your function faster or break large tasks into smaller ones. If you're consistently hitting the timeout, think about whether the task belongs in Lambda at all. For heavy processing, consider using a container service or a step function instead. But for most cases, a little code optimization and a longer timeout solves it just fine.

Another Option: Use the CLI

If you prefer the command line, you can update the timeout using the AWS CLI:

aws lambda update-function-configuration --function-name your-function-name --timeout 30

This sets the timeout to 30 seconds. Replace your-function-name with your actual function name. You'll get a JSON response showing the updated configuration.

That's it. You've fixed the timeout error. If you still see it after all this, double-check that you're saving the configuration and testing the right version. Good luck.

Related Errors in Server & Cloud
AccessDeniedException AWS Lambda Permission Denied: 3 Common Causes & Fixes 0X0000071D RPC_S_UNSUPPORTED_AUTHN_LEVEL (0x0000071d) fix 0X0000139C Fix ERROR_QUORUM_RESOURCE (0X0000139C) on Windows Cluster 0X000008DF Fix Messenger Service Error 0X000008DF Already Started

Was this solution helpful?

EP
Erropedia Team
Tech Support Editors
The Erropedia editorial team researches and documents real-world tech errors from across Windows, Linux, macOS, networking, databases, cloud platforms, and more. Every solution is reviewed for accuracy and updated as software and systems evolve.