Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to RDS Postgres from remote machine

Tags:

I have configured an RDS Postgres micro instance for testing but am having problem connecting. I have created a security group and allow all hosts (0.0.0.0/0) by default to port 5432 but for some reason I am not able to connect. I tried connecting to the port 5432 on the machine but it appears to be closed. Any ideas? I have verified that the security group is using the correct security group.

This is my configuration

TCP Port (Service)  Source  Action 5432    0.0.0.0/0   Delete 

Here is how I am trying to connect to the rds service

psql -p 5432 -h example.cs945smhrv09.us-west-2.rds.amazonaws.com -U example example 

UPDATE

OK feel a little silly after figuring out that rds starts up on a private 172 subnet. I was able to connect from my ec2 instance.

Question now is there a way to put that on a public address that I can connect to? I would like to configure it with a security group that limits the source ip but then be able to connect to it with psql from my desktop.

Update 2

I don't remember all the details when I originally posted this question but it is no longer an issue. We now have a management vpc that we connect to using a vpn server. The management vpc network is trusted by the prod and devel security groups for the rds instances. We have no problem communicating with them without adding any public ips.

like image 889
Chris Hinshaw Avatar asked Dec 06 '13 19:12

Chris Hinshaw


2 Answers

Step 4 of the RDS setup wizard ("Additional Config") lets you select whether the DB is Publicly Accessible or not (if it's not, access is limited to within your VPC, regardless of your security group settings). I'd imagine that determines whether the hostname resolves to 54.* vs 172.* .

Your first instance may have been set to private - as far as I can tell this can't be changed after initialization. I had a similar issue and creating a new instance set to be publicly accessible solved it for me.

like image 173
Gord Stephen Avatar answered Oct 28 '22 14:10

Gord Stephen


My company's firewall had blocked outgoing traffic to the default postgres port, 5432. I didn't realise this until I tested the port using netcat in a terminal window, as follows:

nc -zv portquiz.net 5432 

Hopefully this saves someone half a day of messing around with AWS security groups.

like image 43
J Dawkins Avatar answered Oct 28 '22 15:10

J Dawkins