I am trying to connect to a postgres database from my python script using the psycopg2 library. But I am getting the following error
import psycopg2
conn = psycopg2.connect(host = <hostname>, port = 5432, database = <db_name>, user = <user_name>, password = <password>)
psycopg2.OperationalError: FATAL: no pg_hba.conf entry for host "<MY IP ADDRESS>", user <user_name>, database <db_name>, no encryption
However, my IP address has already been added to the whitelist and I am able to connect to the database from the same computer using PgAdmin and VS Code. So it doesn't appear to be a case of IP whitelisting
Any idea why this might be happening ?
P.S: The postgres database is setup in Azure cloud