Cannot connect RDS PostgreSQL DB instance to IntelliJ or PgAdmin4

0

Hello, I created a PostgreSQL instance in AWS RDS using the default security group which allows all traffic from all ports range as an inbound rule. Besides this I cannot connect my local dev environment to the database, either from IntelliJ (error: The connection attempt failed) or PgAdmin 4 (error: Unable to connect to server: connection timeout expired). I even added a new inbound rule for Postgres's port range (5432) and my IP address (also changed it later to allow any IP address), but still not able to connect. Does someone has any clues why it's not connecting?

2 Answers
0
Accepted Answer

There could be a few possible causes for why your connection is being blocked.

I would start with checking VPC and Subnet configuration. Make sure that the RDS Instance is in a public subnet if you are trying to access it from the internet and make sure that the subnet is associated to a route table with a route to an internet gateway. Alternatively you could keep it in a private subnet and use a bastion host to connect to the private RDS Instance.

I would check security group rules next. It sounds like have done this already, but it never hurts to check again. The default security group does allow all inbound access for instances within that same security group but only within that security group. No other inbound traffic is allowed by default. If you have not already you can always add a rule:

  • Type: PostgreSQL
  • Protocol: TCP
  • Port Range: 5432
  • Source: your IP

Check Network ACLs and ensure that they are not cutting off inbound or outbound traffic to or from the subnet where your RDS lives.

Check Firewall on local machine and ensure outbound traffic on port 5432 is not being blocked.

Verify endpoints, ports, and authentication.

Additional information on these topics can be found below.

Connecting to Amazon RDS PostgreSQL DB Instance

Amazon RDS for PostgreSQL Documentation

Can't Connect to Amazon RDS DB Instance

AWS
answered 11 days ago
0

Thanks a lot for the help David, after many days I found the issue. Using the third document that you attached (Can't Connect to Amazon RDS DB Instance), I had a look on the Internet Gateway step to check if my subnets have a route with 0.0.0.0/0 as the destination. By default there are 6 subnets in total, 3 default ones and 3 additional ones related to RDS. For some reasone, the ones associated with RDS did not had the public route (0.0.0.0/0) and there was no option to allow me to add this new rule. What I did was to navigate to the Route Tables insinde VPC and from the Actions button I selected Edit subnet associations. There I saw that the RDS private routes were selected and I just deselected them and selected the three public ones instead, and then clicked Save associations. After that I was able to connect right away doing this. A bit frustrating that all the tutorials from Google/YouTube only shows the straight-forward database creation and for some reason they are able to connect right away, but neither of them shows these additional steps and it took me a few days to come here and ask for help. Thanks again and have a nice day!

Daniel
answered 10 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions