Why does connection to my Postgres server in Azure fail if my app does not have SSL enabled?

Viewed 34668

I get a connection failure when I try to connect to my postgres server in Azure from my app/client, which does not have SSL enabled.

Unable to connect to server: FATAL: SSL connection is required. Please specify SSL options and retry.

Is this a strong requirement? Is there a way I can circumvent this requirement?

8 Answers

It helps me:

psql -v sslmode=true -h myapp.postgres.database.azure.com -U my_db_admin@myapp postgres

From the docs:

If your PostgreSQL server requires TLS/SSL connections (on by default in Azure Database for PostgreSQL servers), set an environment variable PGSSLMODE=require so that the pg_restore tool connects with TLS. Without TLS, the error may read FATAL: SSL connection is required. Please specify SSL options and retry.

As an example, under Bash that would be export PGSSLMODE=require, then run pg_restore.

In my case, I was getting the following errors

Password for user user@server-name: 
psql: server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
FATAL:  SSL connection is required. Please specify SSL options and retry.

And it was because of the wrong password I had entered. So do check your password if it is wrong it may give similar errors.

Hope this helps for someone...

I've just changed my dependency from

compile group: 'postgresql', name: 'postgresql', version: '8.1-407.jdbc3' 

to
runtimeOnly 'org.postgresql:postgresql' in build.gradle file. It was working fine.

You can disable SSL feature the Azure Cloud itself for the Postgres setup!

enter image description here

Related