Search code examples
postgresqlamazon-web-servicesamazon-ec2

Cannot conect to my aws postgress database in RDS


I created my Postgres database in AWS but it has connection timeouts every time I try to connect (using JDBC or pgadmin). I even added security groups but that didn't help. Text Text Since I'm new in AWS I really have no idea what to do. Should I check any logs or I missed something during set-up?


Solution

  • Some things to check:

    • Database was launched with Publicly Available = Yes (Done!)
    • Security Group permits inbound access from your IP address or 0.0.0.0/0 (Done!)
    • DNS Name resolves to a public IP address (I checked, it does!)
    • Database was launched in public subnets (Defined as having a Route Table entry pointing to an Internet Gateway)
    • Your network permits the traffic (can test on different networks, eg Home vs Office vs Tethered via your phone)

    I tried connecting from my computer and it timed-out too, and I know that my "network permits" such traffic.

    Therefore, it seems likely that the database was launched with a subnet group that contained only private subnets, which are not reachable from the Internet.

    Update:

    It appears that the database has been launched with a Subnet Group that contains private subnets rather than public subnets.

    If you have not yet connected to the database / stored any data, it would be easiest to:

    • Delete the current Amazon RDS instance
    • Create a Subnet Group that contains public subnets
    • Launch a new Amazon RDS instance using the new Subnet Group

    For security, you should adjust the Security Group to only allow access from your IP address (removing the entries for 0.0.0.0/0).