20

I created a basic test PostgreSQL RDS instance in a VPC that has a single public subnet and that should be available to connect over the public internet. It uses the default security group, which is open for port 5432. When I try to connect, it fails. I must be missing something very straightforward -- but I'm pretty lost on this.

Here're the database settings, note that it's marked as Publicly Accessible: RDS Settings

Here're the security group settings, note it's wide open (affirmed in the RDS settings above by the green "authorized" hint next to the endpoint): Security Group settings

Here's the command I'm trying to use to connect:

psql --host=myinstance.xxxxxxxxxx.us-east-1.rds.amazonaws.com \
     --port=5432 
     --username=masteruser 
     --password 
     --dbname=testdb

And this is the result I'm getting when trying to connect from a Yosemite MacBook Pro (note, it's resolving to a 54.* ip address):

psql: could not connect to server: Operation timed out
    Is the server running on host "myinstance.xxxxxxxxxx.us-east-1.rds.amazonaws.com" (54.xxx.xxx.xxx) and accepting
    TCP/IP connections on port 5432?

I do not have any kind of firewall enabled, and am able to connect to public PostgreSQL instances on other providers (e.g. Heroku).

Any troubleshooting tips would be much appreciated, since I'm pretty much at a loss here.

Update

Per comment, here are the inbound ACL rules for the Default VPC: Network ACL configuration

  • 1
    Did you happen to mess with the NetworkACLs? I would look there for a possible setting that could be blocking internet access. – Optichip Jan 3 '15 at 16:57
  • Thanks for the reply! The ACLs appear to not be blocking anything, since the first rule is to allow all ports from all sources, per attached. – Edward Q. Bridges Jan 3 '15 at 21:16
24

The issue was that the inbound rule in the Security Group specified a security group as the source. Changing it to a CIDR that included my IP address fixed the issue.

  • 5
    For anyone who doesn't know how CIDR works; if your IP address is 91.61.76.202 (can find yours using myipaddress.com), set your source as 91.61.76.202/32 – Tom G May 2 '16 at 14:18
  • Would you be willing to take a screenshot of what this solution looks like? – smaccoun Jun 2 '17 at 17:41
  • I would be happy to, but I no longer have this instance online. – Edward Q. Bridges Jun 5 '17 at 1:52
7

Was facing similar issue, and this is how I resolved it:

Click on the security group for the RDS instance and check the inbound rules. You might see something like this:

enter image description here

Have to set the IP range to contain your IP or just select "Anywhere" in the Source dropdown, to make it accessible from localhost or anywhere:

enter image description here

  • Yes this works. I kept the Custom rule that was there and added a new rule which picked up my IP address automatically. – MSC Aug 17 '18 at 3:29
0

Just wanted to add my findings to save someone some time. This solution described above worked on a dev ec2 instance but after i migrated to a new server it stopped working. It turned out both of my RDS instance and EC2 instance were in the same VPC so the RDS instance could not see the public IP that i had added to its security group. To get this working you need to add to the RDS instances security group, the private ip of the EC2 instance that you can find in details.

0

I had similar issue while connecting to postgres . Event though i had publically access true , i was not able to connect.

I added one rule inbound rule in security group and now it is working perfectly fine .

enter image description here

-1

After I created my Postgres instance, my default security group (rds-launch-wizard) only listed my IP address, so I had to add a Type of All Traffic and Source of Anywhere before I could connect. I'm no networking expert, but it's strange that I couldn't connect with my own IP address as an inbound rule.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.