我无法使用 Postgres 连接到 AWS RDS

Max*_*ian 6 postgresql macos terminal rds amazon-web-services

我已经在 aws 上创建了一个实例/数据库,当我尝试通过终端连接到它时,通过运行下面的代码,出现错误。

我在终端中运行的行是:

psql --host=testdb.c7hgibdbsgjm.eu-west-2.rds.amazonaws.com --port=5432 --username=postgres --password --dbname=testdb

它返回的错误是:

psql: error: could not connect to server: could not translate host name "testdb.c7hgibdbsgjm.eu-west-2.rds.amazonaws.com" 
to address: nodename nor servname provided, or not known. 
Run Code Online (Sandbox Code Playgroud)

我花了三天时间阅读相关文档并尝试使其正常工作,但我不知道哪里出了问题。

当我跑步时:

nslookup testdb.c7hgibdbsgjm.eu-west-2.rds.amazonaws.com

它返回:

Non-authoritative answer:
*** Can't find testdb.c7hgibdbsgjm.eu-west-2.rds.amazonaws.com: No answer
Run Code Online (Sandbox Code Playgroud)

我有统计背景,并且已经用 R 和 python 编写了相当多的代码,但我对使用终端等还比较陌生!

感谢您的任何指导或帮助,因为这让我想打我的笔记本电脑。

kad*_*amb 6

运行 dig 命令时: dig testdb.c7hgibdbsgjm.eu-west-2.rds.amazonaws.com

它返回一个私有IP:172.31.23.42

看来您正在将 RDS 实例作为私有或内部运行,即无法从互联网访问它。

您需要从VPC本身访问它或者需要使用VPN。