0

I could use:

psql --host=myrds.crypticxxxx.us-east-1.rds.amzaonaws.com -port=5432 -username='devuser' -dbname='postgre'.

But in the same terminal, with Python 3.7.16, with Amazon, Linux 2, and the Python 3 database package psycopg2.

After importing modules and make a connection like:

conn = psycopg2.connect(host=db_host, user=user_name, password=password, database=db_name, port=port_num, connect_timeout=100) 

ConnectionERROR: Unexpected error: Could not connect to postgresqldb instance. connection to server at "myrds.crypticxxxx.us-east-1.rds.amzaonaws.com" (xx.xx.xx.xxx), port 5432 failed: FATAL: password authentication failed for user "devuser" connection to server at "myrds.crypticxxxx.us-east-1.rds.amzaonaws.com" (xx.xx.xx.xxx), port 5432 failed: FATAL: no pg_hba.conf entry for host xx.xx.xx.xxx, user "devuser", database "postgre", no encryption.

What could be the cause for Python 3 to fail to make a connection?

Tried with the sslmode='require' option as well in Python codes. But there was no connection either.

3
  • See linked answer -- use sslmode='require' Commented Jul 23, 2024 at 6:53
  • when I used sslmode='require' to the connect method. which showed this error: ConectionERROR: Unexpected error: Could not connect to postgresqldb instance. connection to server at "myrds.crypticxxxx.us-east-1.rds.amzaonaws.com" (xx.xx.xx.xxx), port 5432 failed: FATAL: password authentication failed for user ""devuser" Commented Jul 23, 2024 at 15:36
  • Then you have the wrong username or password. Commented Jul 23, 2024 at 23:15

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.