1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-16 05:28:03 +00:00

Add Force SSL When Making A psql Connection as a postgres til

This commit is contained in:
jbranchaud
2021-02-27 18:53:32 -06:00
parent 65a0fe0a9d
commit 59e1c71724
2 changed files with 34 additions and 1 deletions

View File

@@ -0,0 +1,32 @@
# 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:
```bash
$ psql postgres://username:password@host.com/dbname?sslmode=require
```
Or if you're using the connection parameter flags, it may look like this, using
the `--set` flag:
```bash
$ 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](https://dev.to/jbranchaud/reinstall-postgresql-with-openssl-using-asdf-cmj).