diff --git a/README.md b/README.md index c2737eb..fcd4f6c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud). -_1063 TILs and counting..._ +_1064 TILs and counting..._ --- @@ -542,6 +542,7 @@ _1063 TILs and counting..._ - [Find The Data Directory](postgres/find-the-data-directory.md) - [Find The Location Of Postgres Config Files](postgres/find-the-location-of-postgres-config-files.md) - [Fizzbuzz With Common Table Expressions](postgres/fizzbuzz-with-common-table-expressions.md) +- [Force SSL When Making A psql Connection](postgres/force-ssl-when-making-a-psql-connection.md) - [Generate A UUID](postgres/generate-a-uuid.md) - [Generate Random UUIDs Without An Extension](postgres/generate-random-uuids-without-an-extension.md) - [Generate Series Of Numbers](postgres/generate-series-of-numbers.md) diff --git a/postgres/force-ssl-when-making-a-psql-connection.md b/postgres/force-ssl-when-making-a-psql-connection.md new file mode 100644 index 0000000..73ce415 --- /dev/null +++ b/postgres/force-ssl-when-making-a-psql-connection.md @@ -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).