Skip to content

My RDS instance has an inbound rule specifically allowing my Fargate Security Group, but I can't connect.

0

My RDS instance has an inbound rule specifically allowing my Fargate Security Group, but I keep getting:

error: no pg_hba.conf entry for host "xx.x.xx.yyy", user "yyy", database "xx", no encryption

3 Answers
0

When you're experiencing connection issues between Fargate and your RDS PostgreSQL instance despite having the security group inbound rule configured correctly, there are several potential causes for the "no pg_hba.conf entry" error.

This specific error indicates an authentication issue related to PostgreSQL's host-based authentication configuration. Here are some troubleshooting steps:

  1. SSL/TLS Configuration: The error message mentions "no encryption" which suggests an SSL/TLS issue. PostgreSQL might be requiring an encrypted connection. You can resolve this by:
  • Setting ssl: true in your application's connection configuration
  • Or downloading and using the RDS certificate when connecting
  • Alternatively, you could modify the "rds.force_ssl" parameter in the RDS parameter group to 0 (though this is less secure)
  1. Network Configuration: Even with security groups properly configured, check:
  • Network ACLs (NACLs) associated with your subnets to ensure they allow traffic on port 5432
  • Route tables to verify proper routing between Fargate and RDS
  • If your Fargate task is in a private subnet, ensure it has proper routing to reach the RDS instance
  1. Connection String: Verify you're using the correct RDS endpoint in your connection string, not an incorrect IP address

  2. Public Access Setting: If your Fargate task is in a different VPC or subnet arrangement, check if the RDS instance needs public access enabled

If you're still experiencing issues after checking these items, enabling enhanced logging on your RDS instance might provide more detailed error information to help diagnose the problem.
Sources
Troubleshooting connection issues to your Amazon RDS DB instance - Amazon Relational Database Service
Docker container running on an ec2 instance cant connect to RDS AWS | AWS re:Post
Connection timeout white connecting from fargate to document db | AWS re:Post

answered a year ago

EXPERT

reviewed a year ago

0

Hello.

The error is not a security group issue, but rather a problem with not using an SSL connection when connecting to PostgreSQL.
Therefore, please try enabling SSL when connecting on the application side as stated in the automatic response from re:Post Agent.
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/PostgreSQL.Concepts.General.SSL.html

EXPERT

answered a year ago

0

When the rds.force_ssl feature is active … connection attempts that aren't using SSL are rejected with the following message:

FATAL: no pg_hba.conf entry for host "w.x.y.z", user "testuser", database "testDB", SSL off
```” :contentReference[oaicite:2]{index=2}

Here is the documentation link: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/PostgreSQL.Concepts.General.SSL.html

  1. Ensure that SSL is enabled on your RDS PostgreSQL instance. From the AWS Console: In RDS, click on Databases, then select your database, and then click on the Configuration tab. Click the link for the Parameter group.

Look for the rds.force_ssl setting: If the value is 1, SSL is required. This is probably what is causing your connection problem.

  1. Get the AWS RDS CA Certificate You need the right AWS RDS certificate to connect over SSL. https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html

answered a year 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.