[RDS Postgres] failed: Connection timed out

0

Hi, I have multiples postgres database instance on RDS, but, for some reason, out of nowhere, some of them now have no public connection, without any active intervention. What is weird is that I can still connect to some instances with psql. Both instances (the ones I can connect and the ones I can't) have the same:

  • Security Groups (with my ext ip as an inbound rule to postgres)
  • Publicly accessible: Yes
  • VPC
  • Subnets
  • Availability Zone

And their DNS looks ok, which I verified with:

$ nslookup ########.rds.amazonaws.com
Server:         ###.###.###.###
Address:        ###.###.###.######

Non-authoritative answer:
##########.rds.amazonaws.com     canonical name = ##########.amazonaws.com.
Name:   ##########.amazonaws.com
Address: ###.###.###.###

But, when checking with

$ nc -zv ##########.rds.amazonaws.com ####

I get "succeeded" from one, and "nc: connect to ###.###.###.### port #### (tcp) failed: Connection timed out" from the other.

1 Answer
0
Accepted Answer

Hello.

Is there a route to the Internet gateway configured in the subnet where RDS is running?
For example, are all the subnets set in the subnet group public subnets?
https://repost.aws/knowledge-center/rds-connectivity-instance-subnet-vpc
https://repost.aws/knowledge-center/rds-cannot-connect

By the way, public access of RDS is not recommended for security reasons, so I think it is better to connect using Session Manager's port forwarding function as introduced in the document below.
https://aws.amazon.com/jp/blogs/mt/use-port-forwarding-in-aws-systems-manager-session-manager-to-connect-to-remote-hosts/

profile picture
EXPERT
answered 21 days ago
profile pictureAWS
EXPERT
reviewed 20 days ago
  • Hi, There are 3 private subnets and 3 public subnets on this vpc, all 3 public subnets are targeting an internet gateway. The thing is, I can access a database on the same VPC, with the same subnets with the same configurations. About the second solution, we plan on doing it later, but right now I need a fast solution because there are multiple external services accessing my database. It was working, but out of nowhere it stopped working for only some instances, so we need to fix this legacy structure before migrating to another. Is there some configuration specific to each rds instance that needs to be configured? Like inserting its ip somewhere?

  • Update: the other ones also stopped working. I will look into everything again.

  • It looks like my instance has an ip that is outside the range of the vpc

  • In the end made it work using the ssh tunnel with an ec2. Maybe the problem was the private and public subnets inside the same vpc. Thanks!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions