- Newest
- Most votes
- Most comments
Sometimes with lambda functions increasing the Timeout fixes it.
Other things to try:
- Add a Timeout to the DB connection settings:
var connection = mysql.createConnection({
host : 'nnn.nnn.nnn.nnn',
user : 'root',
password : 'my_password',
database : 'my_db',
timeout: 60000
})
-
Update the security group since RDS generates a default group with the local machine IP address. If you are trying to connect to the database from another app that is in another instance, you should add the IP address in the security group.
-
On your Lambda function, specify your VPC, subnets, and Security Groups. Then you need to add the Security Group that you selected on your Lambda function to the Security Group you have defined for your RDS. You have to add the Group Id to the Inbound rules (you can add an IP address or a Group Id to the rules set ).
Your security group rules look fine, if anything they are a bit too wide open but that's good for troubleshooting and you can always tighten them up later. Has the RDS instance been provisioned in a subnet group in which all subnets have a route to an internet gateway associated with them?
Also check that the Publicly accessible property of the database is set to yes - this is in the Connectivity and Security section for the instance in the RDS section of AWS Console.
More troubleshooting suggestions are here https://repost.aws/knowledge-center/rds-connectivity-instance-subnet-vpc
More information on correctly setting up networking for your RDS instances is here https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.WorkingWithRDSInstanceinaVPC.html
Relevant content
- asked a year ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 4 months ago