Connecting to RDS

0

I have created a MySql RDS on AWS and trying to connect to it from Sqlectron and I get the following error "Connection Error Error invoking remote method 'DB_CONNECT': Error: connect ETIMEDOUT". I checked the security inbound rules and below is what is set

MYSQL/Aurora TCP 3306 0.0.0.0/0 –

– All ICMP - IPv4 ICMP All 0.0.0.0/0 –

– All traffic All All

asked 8 months ago600 views
2 Answers
0

Sometimes with lambda functions increasing the Timeout fixes it.

Other things to try:

  1. 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
})
  1. 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.

  2. 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 ).

profile picture
answered 8 months ago
0

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

profile picture
EXPERT
Steve_M
answered 8 months ago
profile pictureAWS
EXPERT
reviewed 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions