Lance Pollard
Lance Pollard

Reputation: 79258

How to connect to RDS Postgres instance with psql

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 tried this with the db name and it still hangs:

$ psql postgresql://myuser:[email protected]:5432/-

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.

Upvotes: 4

Views: 4597

Answers (1)

Amith Jayasekara
Amith Jayasekara

Reputation: 439

I found a useful link in AWS knowledge center, I hope this will help you. Btw if your RDS is deployed in a public subnet, yes you need to enable if you want to access RDS over the internet.

My DB instance is in a public subnet, and I can't connect to it over the internet from my local computer This issue can occur when the Publicly Accessible property of the DB instance is set to No. To check whether a DB instance is publicly accessible, you can use the Amazon RDS Console or the AWS CLI.

To change the Publicly Accessible property of the Amazon RDS instance to Yes:

  1. Verify that your VPC has an internet gateway attached to it. Make sure that the inbound rules for the security group allow connections.

  2. Open the Amazon RDS console.

  3. Choose Databases from the navigation pane, and then select the DB instance.

  4. Choose Modify.

  5. Under Connectivity, extend the Additional configuration section, and then choose Publicly accessible.

  6. Choose Continue.

  7. Choose Modify DB Instance.

Note: You don't need to choose Apply Immediately. For more information about how Apply Immediately can affect downtime, see Using the Apply Immediately parameter.

https://aws.amazon.com/premiumsupport/knowledge-center/rds-connectivity-instance-subnet-vpc/

Upvotes: 2

Related Questions