Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 922 Bytes

force-ssl-when-making-a-psql-connection.md

File metadata and controls

32 lines (24 loc) · 922 Bytes

Force SSL When Making A psql Connection

If you try connecting psql to a Postgres server that requires SSL connections, you'll see an error message like this:

psql: error: FATAL:  SSL/TLS required

You can tell psql to make an SSL connection by adding the sslmode=require key-value pair to the connection.

If you're using a connection string, that might look like this:

$ psql postgres://username:[email protected]/dbname?sslmode=require

Or if you're using the connection parameter flags, it may look like this, using the --set flag:

$ PGPASSWORD=password psql \
    --set=sslmode=require \
    -h host.com \
    -U username \
    dbname

If after adding sslmode=require, you find that SSL support is not compiled in, follow the instructions in this post to reinstall Postgres with SSL support.