psycopg / psycopg2

PostgreSQL database adapter for the Python programming language
https://www.psycopg.org/
Other
3.35k stars 506 forks source link

cannot connect to a AWS RDS PG database via Route53 #1616

Closed tornielsen2022 closed 1 year ago

tornielsen2022 commented 1 year ago

This is a bug tracker

Please complete the following information:

Describe the bug I cannot connect to a AWS RDS PG database via Route53 with psycopg2. Bypassing Route53, it works fine. However, everything equal I can connect to the database via Route using different tools e.g. Navicat.

1: I wrote a simple Python script to connect to an AWS RDS Postgresql DB via its Route53 endpoint "route53_xxx_config.com" 2: I expected the script to connect successfully 3: I got the following exception: connection to server at "route53_xxx_config.com" (10.xxx.xx.xxx), port 5432 failed: FATAL: password authentication failed for user "xxx_config_manager" 4) If I bypass Route53 it works: "direct_config_db.xxxxx.us-west-2.rds.amazonaws.com"

Script reproducing the issue.

import psycopg2 from psycopg2 import sql

class PostgreSQLClient:

def __init__(self, host, dbname, user, password, port=5432):
    self.conn = psycopg2.connect(
        host=host,
        dbname=dbname,
        user=user,
        password=password,
        port=port
    )

def close(self):
    if self.cursor:
        self.cursor.close()
    if self.conn:
        self.conn.close()

------------------------------------------------------------------------------------------------------------

if name == 'main': client = PostgreSQLClient(host="route53_xxx_config.com",

client = PostgreSQLClient(host="direct_config_db.xxxxx.us-west-2.rds.amazonaws.com",

                          dbname="config", 
                          user="config_manager", 
                          password="xyz_secret")

# Status
print("SUCCESS")

client.close()
dvarrazzo commented 1 year ago

AWS is not supported for free. Please get in touch privately if you would like to purchase a paid consultancy.

tornielsen2022 commented 1 year ago

I did not expect AWS support here (I have a ticket opened with AWS already). Just wondering if this case is a known challenge.