Vapor Framework: setting up postgres connection with SSL

I am trying to connect to my Heroku PostgreSQL database, but I have the following error:

cannotEstablishConnection("FATAL:  no pg_hba.conf entry for host \"37.167.93.189\", user \"clpnkpyttmdtyq\", database \"d3h6147v73mgtu\", SSL off\n")

I know that Heroku postgres databases should use an SSL connection, but I don't know how to configure the connection on my object Droplet.

This is my configuration file postgresql.json:

{
    "host": "ec2-54-163-224-108.compute-1.amazonaws.com",
    "user": "clpnkpyttmdtyq",
    "password": "99201aa07c48e18e7bdf210937857b85bee37cd8d8cb904381b1ddff934c7a4f",
    "database": "d3h6147v73mgtu",
    "port": 5432
}

Maybe there is a parameter sslthat I do not know?

How to add VaporPostgresSQLProvider:

let drop = Droplet()

// Tell the droplet to use our SQL provider service
try drop.addProvider(VaporPostgreSQL.Provider.self)

Any ideas?

When I try to use my local postgres database, it works because it does not need an ssl connection.

+4
source share
1 answer

, , ,


Config > secrets > postgresql.json ( , , )

{
   "host": "127.0.0.1",
   "user": "your_user_pc", 
   "password": "",
   "database": "your_user_pc",
   "port": 5432
}

$ cd ~

Procfile ( , finder)

web: App --env=production --workdir="./"
web: App --env=production --workdir=./ --config:servers.default.port=$PORT --config:postgresql.url=$DATABASE_URL

heroku, , heroku Postgresql Heroku

. , , " " " - "

0

Source: https://habr.com/ru/post/1664314/


All Articles