Connecting to Azure PostgreSQL server from python psycopg2 client

Petr Svec 101 Reputation points
2020-07-23T14:47:58.76+00:00

Hello,
I have trouble connecting to the Azure postgres database from python. I am following the guide here - https://learn.microsoft.com/cs-cz/azure/postgresql/connect-python
But the psycopg2 and SQLalchemy throw me the same error:

OperationalError: server closed the connection unexpectedly  
 This probably means the server terminated abnormally  
 before or while processing the request.  

I am able to connect to the instance by other client tools like dbeaver but from python it does not work.

When I investigate in Postgres logs I can see that the server actually authorized the connection but the next line says

could not receive data from client: An existing connection was forcibly closed by the remote host.  

psycopg's version is 2.8.5
Azure Postgres region is in West Europe

Do you have any suggestion on what to try to debug this?

Thank you!

Azure Database for PostgreSQL
{count} vote

0 additional answers

Sort by: Most helpful