无法连接到我的AWS数据库实例|psql:无法连接到服务器:操作超时 [英] Can't connect to my AWS Database Instance | psql: could not connect to server: Operation timed out

查看:134
本文介绍了无法连接到我的AWS数据库实例|psql:无法连接到服务器:操作超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在AWS RDS上创建了一个postgres数据库实例.我正在尝试将此数据库实例连接到我的django zappa应用程序,以便可以执行AWS Lambda函数.

I created a postgres DB instance on AWS RDS. I am trying to connect this DB instance to my django zappa app so I can perform AWS Lambda functions.

我已经向数据库实例添加了一个新的安全组,这样我就可以允许我的django应用程序连接到它:

I've added a new security group to my DB instance so I can allow my django app to connect to it:

我的数据库详细信息显示新的安全组处于活动状态:

My DB details show that the new security group is active:

但是,当我尝试连接到它时,可以通过运行 psql --host ="*************.us-east-2.rds.amazonaws.com"--port ="5432" --username ="*********" --password --dbname ="*****" 通过我的终端,

However when I try to connect to it, either by running psql --host="*************.us-east-2.rds.amazonaws.com" --port="5432" --username="*********" --password --dbname="*****" via my terminal,

或通过我的pgadmin界面,它返回此错误:

or via my pgadmin interface, it returns this error:

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

知道为什么要这么做吗?

Any idea why it does this?

推荐答案

最常见的错误是不允许自己访问/未设置为公共可访问性.

The most common error is not having allowed yourself access/not set to public accessibility.

  1. 确保将RDS数据库实例标记为公开访问(更改为是".
  1. Ensure that the RDS DB instance was marked as publicly accessible (change to YES.

如果要使EC2实例和托管数据库实例的VPC外部的设备连接到数据库实例,请选择是".如果选择否,则Amazon RDS将不会为数据库实例分配公共IP地址,并且VPC之外的任何EC2实例或设备都将无法连接.如果选择是",则还必须选择一个或多个VPC安全组,这些安全组指定哪些EC2实例和设备可以连接到数据库实例.

Select Yes if you want EC2 instances and devices outside of the VPC hosting the DB instance to connect to the DB instance. If you select No, Amazon RDS will not assign a public IP address to the DB instance, and no EC2 instance or devices outside of the VPC will be able to connect. If you select Yes, you must also select one or more VPC security groups that specify which EC2 instances and devices can connect to the DB instance.

  1. 确保您已允许自己访问安全性RDS数据库的组.您应该添加或更改当前的入站规则,以允许您的ip(或者不得已使用0.0.0.0/0-互联网上的任何人都可以连接)来访问端口上的RDS.默认情况下,出站规则已设置为0.0.0.0/0
  1. Make sure you've allowed yourself access in the Security Group of the RDS database. You should add or change the current inbound rule to allows your ip (or 0.0.0.0/0 as a last resort - anyone on the internet will be able to connect) to access the RDS on your port. By default the outbound rule is already set as 0.0.0.0/0

这篇关于无法连接到我的AWS数据库实例|psql:无法连接到服务器:操作超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆