Can't connect to my AWS Database Instance | psql: could not connect to server: Operation timed out

泄露秘密 提交于 2021-02-18 17:08:17

问题


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.

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:

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,

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?


回答1:


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

  1. Ensure that the RDS DB instance was marked as publicly accessible (change to YES.

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. 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


来源:https://stackoverflow.com/questions/50984887/cant-connect-to-my-aws-database-instance-psql-could-not-connect-to-server-o

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!