
Let's say you are getting something like this when submitted a request to your Lambda Function.
2023-12-27T03:50:43.460Z d864fc69-9b31-4a3a-a7e3-55b417964805 Task timed out after 3.00 seconds
For example, I was getting this with my Python Lambda Function that was submitting a POST request to the Lambda Function, something like this. So, there are actual two POST requests here. First the POST request from AWS API Gateway into the Lambda Function and then another POST request from the Lambda Function to http://www.example.com/api.
import json
import requests
def lambda_handler(event, context):
response = requests.post(
"http://www.example.com/api",
json={"foo": "hello world"}
)
return {
'statusCode': 200,
'body': json.dumps({
"response": response
})
}
The most likely reason "task timed out" is returned is because the task run time indeed exceeded the timeout with the Lambda Function.
The aws lambda list-functions command can be used to see the timeout of the Lambda Function. In this example, the Lambda Function will timeout after 3 seconds.
~]$ aws lambda list-functions --query 'Functions[?FunctionName==`myfunction`]'
[
{
"FunctionName": "myfunction",
"Timeout": 3
The aws lambda update-function-configuration command can be used to increase the timeout.
aws lambda update-function-configuration --function-name myfunction --timeout 6
Did you find this article helpful?
If so, consider buying me a coffee over at