I was using the AWS free tier to setup my Rails project.
However, I felt confused about why I can't connect RDS
via sequel pro
.
Here is the VPC
security group
which RDS
was using.
I set the same host, username, pwd and database name in my rails database.yml
.
My Rails project on EC2
can connent to RDS
perfectly, but it fails to connect from sequel pro.
Lack of connectivity to RDS instance from outside VPC, while access from VPC works fine is usually related to RDS' DNS name not resolving outside VPC. Set Publicly accessible
setting of your database to yes
to be able to connect from outside.
From AWS docs - Hiding a DB Instance in a VPC from the Internet:
When you launch a DB instance inside a VPC, you can designate whether the DB instance you create has a DNS that resolves to a public IP address by using the PubliclyAccessible parameter. This parameter lets you designate whether there is public access to the DB instance. Note that access to the DB instance is ultimately controlled by the security group it uses, and that public access is not permitted if the security group assigned to the DB instance does not permit it.
You can modify a DB instance to turn on or off public accessibility by modifying the PubliclyAccessible parameter. This parameter is modified just like any other DB instance parameter. For more information, see the modifying section for your DB engine.
NOTE: Opening any port in your RDS' security group for 0.0.0.0/0
CIDR range is a dangerous practice. Be specific and set up only source IPs that should be able to connect to your RDS instance in the security group.