How to fix Task timed out after 6.00 seconds error [Serverless Framework][AWS Lambda]

Tadashi Shigeoka ·  Sat, December 15, 2018

I’ll introduce how to fix the Task timed out after 6.00 seconds error when a function deployed to AWS Lambda with Serverless Framework encounters this issue.

Serverless Framework

(Prerequisite) AWS Lambda default timeout is 6 seconds

According to the official documentation and forums, the default timeout for AWS Lambda appears to be 6 seconds.

# serverless.yml
provider:
  timeout: 10 # The default is 6 seconds. Note: API Gateway current maximum is 30 seconds

functions:
  usersCreate: # A Function
    timeout: 10 # Timeout for this specific function.  Overrides the default set above.

How to fix Task timed out after 6.00 seconds

Since The default is 6 seconds., I resolved this by extending the timeout setting for the function that timed out to 60 seconds.

diff --git a/serverless.yml b/serverless.yml
index 789903d..08183dc 100644
--- a/serverless.yml
+++ b/serverless.yml
@@ -57,6 +57,7 @@ provider:
 functions:
   hello:
     handler: handler.hello
+    timeout: 60 # The default is 6 seconds. Note: API Gateway current maximum is 30 seconds
 
 #    The following are a few example events you can configure
 #    NOTE: Please make sure to change your handler code to work with those events

That’s all from the Gemba where I resolved the Task timed out after 6.00 seconds error.