DEV Community

alade lekan
alade lekan

Posted on • Originally published at Medium

Top 3 Effective Methods To Fix Database connection issues on AWS RDS(Postgres)

Photo by [Kevin Ku](https://unsplash.com/pt-br/@ikukevk?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)

Solving connection errors while connecting to AWS RDS remotely has been one of the trickiest things during development and deployment due to issues like misconfiguration, incorrect credentials, etc. However, in this tutorial, we will learn how to fix these issues using 3 different approaches.

Prerequisites

  1. Familiar with AWS

  2. Knowledge of Database (Postgres)

Method 1:

Make sure your database is publicly accessible.

To confirm if your database is accessible, follow the steps below:

Go to your RDS, and select your database instance to check if it is publicly accessible, if it is not accessible, click on modify, under Connectivity, click on additional configuration, and select Publicly accessible.

With these, you can easily access your database instance remotely.

Method 2:

Add Your IP address to the VPC security group(firewall).

Make sure your local IP is added to the VPC security group firewall to allow incoming connections from your IP using these steps

Go to your RDS, select your database instance, under your connectivity and security, and click your default security group under VPC security groups.

In the security groups page, make sure the default security group is selected, and scroll down to check if the inbound rules have the following rules above, if not, then you need to add an inbound rule. To add inbound rules, click on Edit inbound rules.

Click on Add rule

Select your preferred type, in this article, Postgres is the preferred DB, to add your IP: select custom and type your IP inside the box next to the source.

By following the step above, you have access to the database remotely.

Method 3:

Check if Subnets in your default VPC have access to the internet gateway

Make sure your RDS default VPC and subnets have access to the internet gateway. Check if the Route table for each subnet has a route ID attached to it, kindly follow the steps below.

Go to your RDS, select your database instance, under your connectivity and security, and click each subnet under Subnets to confirm if a Route table is attached to it.

On the subnet page, Select the desired subnet, and check the Route table to see if a value is attached to it.

If false, then click on Route tables to copy a route table id attached to your VPC. Then navigate back to your subnet page, under the subnet details, click the Route Table tab, to attach the route table ID you copied.

Click on the Edit route table association

Paste the copied route table id into the Route table ID select box, then choose it and save it.

Summary

Solving database connection issues is tricky but straightforward. Most of the time, it is either due to internet connectivity or misconfiguration that causes major issues when interacting with the database on AWS. I hope this helps you solve your issue. Kindly check AWS documentation if the above solutions do not help solve your connection issues

Top comments (0)