Home:ALL Converter>How to connect to RDS Postgres instance with psql

How to connect to RDS Postgres instance with psql

Ask Time:2021-08-11T10:47:32         Author:Lance

Json Formatter

I am brand new to RDS and have only used postgres through Rails and/or Heroku for the most part, so not that deep into database management. All I am trying to do is verify I can connect to the RDS instance I just created on AWS, but it is hanging, psql reporting this after hanging for about 30 seconds or a few minutes I guess:

$ psql postgresql://myuser:[email protected]:5432/my-db-name
psql: error: could not connect to server: Operation timed out
  Is the server running on host "myawshost.rds.amazonaws.com" (<the ip address>) and accepting
  TCP/IP connections on port 5432?

How do I connect to my AWS RDS instance from localhost?

  • I am sure I have the correct username and password.
  • I am sure the host is correct.
  • I am not sure if I should be including the port.
  • I am not sure if I am supposed to put a DB name, as under the "Configuration" tab in the RDS admin console for my database, it says DB instance ID: my-db-name, Engine version: 13.3, DB name: -, I am not sure if that - is my actual postgres db name or my-db-name is....

I tried this with the db name and it still hangs:

$ psql postgresql://myuser:[email protected]:5432/-
  • I edited the security group which is linked under the VPC security groups section of the Connectivity & security tab of https://console.aws.amazon.com/rds/home, so it allows all incoming connections. I also tried limiting to just my IP address as incoming connections.

Any help would be appreciated, thanks. Not sure why it would just be hanging. I have used a local version of postgres just fine, but connecting to postgres RDS is not working.

Underneath the Connectivity and Security > Security section I just noticed it says Public accessibility: No. Must I enable something else? There is also one VPC, one Subnet group, and several Subnets, which I don't know too much about, must I do something there?

Finally, "status" says Available with a green light, so things seem fine there.

Author:Lance,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/68735423/how-to-connect-to-rds-postgres-instance-with-psql
yy