Connect to RDS from EC2 instance -- both inside VPC
Just create a new securitygroup with 5432 as inbound TCP connection and replace current security group on your RDS instance with the newly created one.
Related videos on Youtube
wrongusername
Updated on September 18, 2022Comments
-
wrongusername almost 2 years
I have a VPC with two private subnets (two were required to get an RDS instance set up). I have a security group for this VPC, let's call it
vpc-sg
.vpc-sg
allows TCP access on port 22 from my home machine, and allows all outbound traffic. That's it.I have a public-facing EC2 server launched inside the VPC, that I've attached a public Elastic IP to. I'm using the EIP to ssh into this EC2 server. I set the security group to
vpc-sg
. I installed PostgreSQL 9.2 on the EC2 instance.I have an RDS instance within the same VPC. It's using
vpc-sg
for a security group too. I was forced to pick PostgreSQL version 9.3 when creating the instance. I try accessing the RDS PostgreSQL database from my EC2 instance:[ec2-user@ip-10-0-0-20 ~]$ psql the_db_name -U the_db_username -h my-db-instance.random-string.us-east-1.rds.amazonaws.com -p 5432 -W Password for user the_db_username: psql: could not connect to server: Connection timed out Is the server running on host "my-db-instance.random-string.us-east-1.rds.amazonaws.com" (10.0.0.147) and accepting TCP/IP connections on port 5432?
What should I be doing?
EDIT -- I am getting the No Inbound Permissions error on RDB, but don't know how to fix it.
-
Drew Khoury almost 10 yearsHave you opened port 5432 on the RDS service?
-
wrongusername almost 10 years@DrewKhoury Probably not. How do I do that?
-
Chida almost 10 yearsJust create a new securitygroup with 5432 as inbound TCP connection and replace current security group on your RDS instance with the newly created one.
-
-
Dhruba Adhikari over 9 yearsIs the solution still valid in 2014 ?
-
dubvfan87 over 8 yearsNope, doing through this through security groups are "Classic" EC2 now.