My application which is hosted on EC2 instance which is in private subnet is not connecting with RDS which is in private subnet

0

My application is hosted in Ec2 instance(windows) and MySQL database in AWS RDS. Since both Ec2 instance(windows) and RDS MySQL both are in same vpc same region and on private subnet, my application is not connecting with RDS database.

Tried by adding security group but it doesnt help. Please provide suggestion to connect my Ec2 instance and RDS. So that my application should connect with database.

Subha
asked 10 days ago86 views
2 Answers
0

Hello.

If you encounter an error when connecting, could you please share the error message?
Also, could you please share your EC2 security group settings and RDS security group settings?

If you get a timeout error, you may need to check the settings of your security group, subnet network ACL, Windows firewall, etc.
https://repost.aws/knowledge-center/rds-cannot-connect

You also need to make sure that "enableDnsHostnames" and "enableDnsSupport" are enabled in your VPC.
https://docs.aws.amazon.com/vpc/latest/userguide/vpc-dns.html#vpc-dns-support
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.WorkingWithRDSInstanceinaVPC.html

If you want your DB instance in the VPC to be publicly accessible, make sure to turn on the VPC attributes DNS hostnames and DNS resolution.

profile picture
EXPERT
answered 10 days ago
profile pictureAWS
EXPERT
reviewed 10 days ago
  • Hi Riku, Didier, Thanks for your suggestion. As like steve said assumption only had my security groups. And also, "enableDnsHostnames" and "enableDnsSupport" enabled in my VPC.

0

Ec2 instance(windows) and RDS MySQL both are in same vpc same region and on private subnet

Can you confirm that the EC2 instance and RDS instance are in the same subnet?

Tried by adding security group but it doesnt help.

Which security group settings did you try? Assuming that MySQL is running on its default port 3306, your EC2 instance will need a security group with an outbound rule allowing TCP port 3306 to the RDS instance's private IP address (or subnet, or just make it 0.0.0.0/0 for troubelshooting, you can tighten it later). On the RDS instance, it will need a security group associated with it which has an inbound rule allowing TCP port 3306 from the EC2 instance's private IP address (or subnet, or again just make it 0.0.0.0/0 to get it working).

profile picture
EXPERT
Steve_M
answered 10 days ago
  • Hi Steve, Thanks for your update. Ec2 instance and RDS are in subnet. As like your assumption only i have configured security groups of RDS and EC2. My application which is hosted on IIS in windows server Ec2 instance is not connecting with Mysql RDS database.

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