Can't connect the Amazon rds database in Amazon ec2?

I have a console application with Amazon rds connection with Entity Framework. It works well on my local PC. But when I launch my application on Amazon EC2, it cannot connect to my Amazon RDS database and say: "The main provider does not work when opened." My entity structure join string ...

<add name="MyEntities" connectionString="metadata=res://*/YhFinModel.csdl|res://*/YhFinModel.ssdl|res://*/YhFinModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=datasourcename,portnumber;initial catalog=databasename;persist security info=True;user id=userid;password=password;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 

Thanks in advance.

+4
source share
3 answers

Have you looked at your security groups? I think you will need to add the EC2 security group that you use in order to have ports access to your RDS instance.

+12
source

If you have an EC2 instance and an RDS instance in different regions, you will need to go to the RDS Security Group and enter the external IP address of the EC2 instance as CIDR / IP. At least what worked for me.

+3
source

This is a slightly newer version that should have made it work. Press the RDS control panel. Select your RDS instance-> Click the Details icon → Click the URL of the security groups where the selected RDS instance is installed. This will lead you to the EC2 security group settings. After selecting a security group, go to the Inbox tab. Here you need to change or create a new rule (MS SQL, TCP, Port (for example, 1433), and then the range of valid IP address / IP address requests. You can set all IP addresses to confirm that it works, and then tighten to the security level to instance-based IP addresses and / or the test environment IP address.

good luck.

0
source

Source: https://habr.com/ru/post/1479802/


All Articles