无法连接到AWS的PostgreSQL RDS。

huangapple go评论70阅读模式
英文:

Can't connect to AWS postsql RDS

问题

I'm trying to stand up a Dev database for a web app. I have setup the Dev database using a snapshot from the current prod server. I'm currently trying to restore the dev server's DB from a .dmp file I have via:

psql --host=blahblahblahblah.us-east-1.rds.amazonaws.com --port=5432 --username=postgres --password --dbname <dbname> -f backup.sql

Which gives me the error:

psql: error: connection to server at "awseb-e-gjem7uperk-stack-awsebrdsdatabase-1hzzq9r4a74c.cg7ksxih0nnz.us-east-1.rds.amazonaws.com" (3.225.21.170), port 5432 failed: Operation timed out
Is the server running on that host and accepting TCP/IP connections?

I believe I have followed all the recommended steps:

  1. Check that the host name used is the DB instance endpoint and that the port number used is correct - yes, they are correct. I copied directly from the RDS Connectivity & security page.

  2. Make sure that the DB instance's public accessibility is set to Yes.

  3. Make sure that the user connecting to the database has CONNECT access to it - (THIS ONE I'M NOT SURE ABOUT How can I do this if I can't connect?)

  4. Check that the security group assigned to the DB instance has rules to allow access - I have access to everybody. I know it's not best practice, but I'm trying to get it to work right now.

Any ideas what is causing me to not connect?

英文:

I'm trying to stand up a Dev database for a web app. I have setup the Dev database using a snapshot from the current prod server. I'm currently trying to restore the dev server's DB from a .dmp file I have via:

psql --host=blahblahblahblah.us-east-1.rds.amazonaws.com --port=5432 --username=postgres --password --dbname &lt;dbname&gt; -f backup.sql

Which gives me the error:

psql: error: connection to server at &quot;awseb-e-gjem7uperk-stack-awsebrdsdatabase-1hzzq9r4a74c.cg7ksxih0nnz.us-east-1.rds.amazonaws.com&quot; (3.225.21.170), port 5432 failed: Operation timed out
	Is the server running on that host and accepting TCP/IP connections?

I believe I have followed all the recommended steps to debug.

  1. Check that the host name used is the DB instance endpoint and that the port number used is correct - yes, they are correct. I copied directly from the RDS Connectivity & security page.

  2. Make sure that the DB instance's public accessibility is set to Yes:

无法连接到AWS的PostgreSQL RDS。

  1. Make sure that the user connecting to the database has CONNECT access to it - (THIS ONE I'M NOT SURE ABOUT How can I do this if I can't connect?)

  2. Check that the security group assigned to the DB instance has rules to allow access - I have access to everybody. I know it's not best practice, but I'm trying to get it to work right now

无法连接到AWS的PostgreSQL RDS。

无法连接到AWS的PostgreSQL RDS。

Any ideas what is causing me to not connect?

EDIT:

You can see my VPC/Internet gateway connection here:

无法连接到AWS的PostgreSQL RDS。

See subnet connected to VPC group:

无法连接到AWS的PostgreSQL RDS。

I also added a new group to allow all traffic, but still not working:

无法连接到AWS的PostgreSQL RDS。

See subnet routing here:

无法连接到AWS的PostgreSQL RDS。

See Routes here:

无法连接到AWS的PostgreSQL RDS。

ACL looks fine too:
无法连接到AWS的PostgreSQL RDS。

答案1

得分: 0

请确保您的VPC已附加互联网网关。

英文:

Please make sure you have Internet Gateway attached to your VPC.

答案2

得分: 0

问题是我的子网。这里是来自AWS re:Post表单的答案:

根据你在stackoverflow帖子中的截图,该实例已被恢复到一个包含12个子网的子网组中。但是路由表只与六个子网关联。

我通过以下步骤解决了这个问题:进入我的VPC -> 路由表 -> 子网关联选项卡 -> 编辑子网关联 -> 添加所需的子网(我只添加了所有子网)
无法连接到AWS的PostgreSQL RDS。

英文:

Ok, so the problem was my subnets. This was the answer from an AWS re:Post form:

By the looks of the screenshots in your stackoverflow post, the instance has been recovered into a subnet group with 12 subnets. But the routing table only has six subnets associated with it.

I did this by going to my VPC -> the routing table -> Subnet Association Tab -> Edit Subnet Association -> add required subnets (I just added them all)
无法连接到AWS的PostgreSQL RDS。

huangapple
  • 本文由 发表于 2023年6月26日 13:54:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76553853.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定