Top 3 Effective Methods To Fix Database connection issues on AWS RDS(Postgres)
Tags: aws, database, postgres, networking
Published: 2023-06-09 21:39:23


![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)](https://cdn-images-1.medium.com/max/6706/0*FEwB0q9ihD9wkytF)

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**.

![](https://cdn-images-1.medium.com/max/5304/1*d6nRKunxGNEDzxow686d7Q.png)

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.

![](https://cdn-images-1.medium.com/max/3212/1*KhS1vpIs0g1aI2U42hRc6Q.png)

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.**

![](https://cdn-images-1.medium.com/max/5500/1*koAjbymBSooDsf6bCN-TDg.png)

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**.

![](https://cdn-images-1.medium.com/max/6496/1*R-QtLo5YGZelgsDUG1bmTQ.png)

Click on **Add rule**

![](https://cdn-images-1.medium.com/max/6096/1*4JO6acsFYu_zWgGkeUJcdA.png)

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.

![](https://cdn-images-1.medium.com/max/6164/1*2aOWsees90KFQ-ALOkbefA.png)

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

![](https://cdn-images-1.medium.com/max/7496/1*hXLMDZfpxHwC8Dg5SLO_kQ.png)

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.

![](https://cdn-images-1.medium.com/max/7652/1*ha2Qa-OXZGJmYSgqxygtuw.png)

Click on the **Edit route table association**

![](https://cdn-images-1.medium.com/max/3492/1*YYWkbAbKhRN-eqSQ5uP1nQ.png)

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](https://aws.amazon.com/rds/) if the above solutions do not help solve your connection issues