graphile / crystal

🔮 Graphile's Crystal Monorepo; home to Grafast, PostGraphile, pg-introspection, pg-sql2 and much more!
https://graphile.org/
Other
12.63k stars 572 forks source link

Add note to the README explaining `?ssl=1` connection string requirement #357

Closed pyrossh closed 6 years ago

pyrossh commented 7 years ago

I'm trying to connect to my database hosted by https://aiven.io/ but getting some configuration error do you know what it could be

web_1       | > Using "webpack" config function defined in next.config.js.
web_1       | error: no pg_hba.conf entry for host "14.142.150.34", user "avnadmin", database "defaultdb", SSL off
web_1       |     at Connection.parseE (/usr/src/app/node_modules/pg/lib/connection.js:554:1

Its connecting fine using psql cli. So why isn't postgraphql connecting? Don't you set ssl to true? That seems to be the problem.

pyrossh commented 7 years ago

My connection string is like this, postgres://demo:demo@demo.aivencloud.com:12627/defaultdb?sslmode=require It seems sslmode is not being honored?

benjie commented 7 years ago

@pyros2097 The error states "SSL off" but it looks like your connection URL wants SSL; it seems that the postgres query string library doesn't support sslmode=require instead requiring ssl=1; my connection string looks like:

postgresql://username:password@example.com/dbname?sslmode=require&ssl=1

pyrossh commented 7 years ago

Yes it worked thanks @benjie :) :+1:

benjie commented 7 years ago

Reopening as a task.

pencilcheck commented 6 years ago

Starting to getting this error, with the latest version of postgraphql weird. I'm using heroku and I can't change DATABASE_URL as it is audo-generated and it is locked. I wonder if there is an easier way to do this via more command line approach. Does postgraphql provide any flag like ssl=true?

benjie commented 6 years ago

Something like this in your Procfile should work:

web: DATABASE_URL=“$DATABASE_URL?ssl=1” postgraphile ...

Failing that a bash script that does the same.

pencilcheck commented 6 years ago

I ended up doing similar things, by doing something like "${DATABASE_URL-default}?ssl=1" in the parameter