CodexBloom - Programming Q&A Platform

AWS Lambda Function Timing Out When Accessing RDS Aurora in VPC

πŸ‘€ Views: 43 πŸ’¬ Answers: 1 πŸ“… Created: 2025-08-24
aws lambda rds vpc timeout JavaScript

I'm deploying to production and I'm writing unit tests and Does anyone know how to Hey everyone, I'm running into an issue that's driving me crazy....... I'm working with a timeout scenario with my AWS Lambda function when trying to connect to an RDS Aurora database that is within a VPC. The function is set to run in the same VPC and subnet as the RDS instance, but it appears the Lambda is not able to communicate with the database efficiently. The behavior I'm seeing is: `Task timed out after 6.00 seconds`. I've tried increasing the timeout settings in the Lambda configuration, but it seems that the scenario is related to the network setup rather than the execution time itself. I've set up the Lambda function with the following configuration: ```json { "FunctionName": "myLambdaFunction", "Runtime": "nodejs14.x", "Role": "arn:aws:iam::123456789012:role/service-role/myLambdaRole", "Handler": "index.handler", "Timeout": 15, "VpcConfig": { "SubnetIds": ["subnet-abc123"], "SecurityGroupIds": ["sg-abc123"] } } ``` I have also ensured that the security group associated with the RDS instance allows inbound traffic from the Lambda's security group on the appropriate port (3306 for MySQL). However, when I test the function, it doesn’t seem to reach the database at all. Additionally, I’ve verified that the IAM role attached to the Lambda function has the necessary permissions to access the RDS services. I've tested the database connection from an EC2 instance in the same subnet, which works perfectly, so I suspect something is off with the Lambda execution environment. Has anyone encountered similar issues, or does anyone have insights on what might be misconfigured in the VPC setup that could cause this timeout? Any best practices or troubleshooting steps would be greatly appreciated! I'm working in a macOS environment. What am I doing wrong? I recently upgraded to Javascript 3.10. Has anyone dealt with something similar? This is for a CLI tool running on CentOS. Any advice would be much appreciated.