2
votes

I am attempting to query a MySQL database from a java program on EC2. My database is stored on Amazon Web Services (AWS) RDS.

When I test my java program from my local tomcat server, I successfully query the RDS database. However, when I query my RDS database from my EC2 instance, I fail to connect.

In my attempts to solve this problem, I investigated my security settings. I've set up an RDS security group associated with my EC2 Security group that is associated with my instance. In my EC2 security group I've enabled all types of inbound traffic to all ports.

Other answers to similar questions suggest that setting up the RDS security groups to accept connections from the EC2 instance is the resolution to this problem. However, I have seemingly done this, yet cannot connect from my EC2 instance (but can from my local machine).

Am I overlooking something?

1
Please elaborate on "I have seemingly done this".eggyal
"I have seemingly done this" means: 1) I created an EC2 security group associated with my instance. (Technically I think this was created automatically). 2) I created an RDS security group associated with my EC2 security group. 3) I added my RDS security group to my database. Did I miss something?digiplant
Did anyone figure this out? I am having the same problem and can't get anywhere with it.cafman

1 Answers

0
votes

My guess would be, your EC2 instance is probably in different VPC , and you have made the RDS db instance private or you did not launch it in the specific vpc where your EC2 instance is located in.