2
votes

I recently created an EC2 instance within Amazon hosting. I also have a MySQL RDS instance that I want to use with the deployment (MVC and EF with .net connector). I am using default VPC. I am able to access the RDS with my local MYSQL workbench on the endpoint xxx.xxx.us-west-2.rds.amazonaws.com:3306 since I added for inbound and outbound rules to the security group: MYSQL TCP 3306 0.0.0.0/0 All traffic All All 0.0.0.0/0

However, my deployment is not able to access the RDS instance with the same endpoint. I am getting error:

          System.Data.Entity.Core.EntityException: The underlying provider     failed on Open. 
---> MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts. ---> System.Net.Sockets.SocketException: The requested name is valid, but no data of the requested type was found
       at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
       at System.Net.Dns.GetHostEntry(String hostNameOrAddress)
       at MySql.Data.Common.MyNetworkStream.CreateStream(MySqlConnectionStringBuilder settings, Boolean unix)
       at MySql.Data.Common.StreamCreator.GetTcpStream(MySqlConnectionStringBuilder settings)
       at MySql.Data.MySqlClient.NativeDriver.Open()
       --- End of inner exception stack trace ---
       at MySql.Data.MySqlClient.NativeDriver.Open()
       at MySql.Data.MySqlClient.Driver.Open()
       at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
       at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
       at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
       at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
       at MySql.Data.MySqlClient.MySqlPool.GetConnection()
       at MySql.Data.MySqlClient.MySqlConnection.Open()

I did install the .Net connector on the EC2. I don't understand why my local MySQL can connect to the remote RDS but an EC2 running in the same VPC and security group can not. Help would really be appreciated , thanks.

UPDATE: It seems that the EC2 has no internet access. When I ping google.com, it says ping can not find host google.com. The EC2 instance does have an elastic IP.

1

1 Answers

2
votes

You have to configure an internet gateway in your VPC and enable 0.0.0.0 traffic in your routing table to the internet gateway to allow internet access from your EC2 instance. AWS documentation

for example:

enter image description here