[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 回答
0
已接受的回答

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
专家
已回答 1 个月前
profile pictureAWS
专家
已审核 1 个月前
  • 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!

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则