I have 2 apps in Heroku with same code version, both using Heroku Postgres with plan free (Hobby). But they were created in different time, some months of difference.
And the problem is, the first work fine, but the second thows error on start
error: no pg_hba.conf entry for host "210.221.51.3", user "byhoyaaasdevfr", database "darcnk9hucbap", SSL off
I read about use SSL, but I want to keep the free plan, and the first app work fine without. This is the connection file content:
const parse = require("pg-connection-string").parse;
const config = parse(process.env.DATABASE_URL);
module.exports = ({ env }) => ({
defaultConnection: "default",
connections: {
default: {
connector: "bookshelf",
settings: {
client: "postgres",
host: config.host,
port: config.port,
database: config.database,
username: config.user,
password: config.password,
},
options: {
ssl: false,
},
},
},
});
Changing the options ssl to true throws
error Error: self signed certificate
Strapi 3.1.5
Thanks for your attention, you are amazing.
We ran into the same issue today and fixed it by updating our config/env/production/database.js
with the one provided by Strapi for Heroku:
const { parse } = require("pg-connection-string");
module.exports = ({ env }) => {
const { host, port, database, user, password } = parse(env("DATABASE_URL"));
return {
defaultConnection: "default",
connections: {
default: {
connector: "bookshelf",
settings: {
client: "postgres",
host,
port,
database,
username: user,
password,
ssl: { rejectUnauthorized: false }
},
options: {
ssl: false
},
},
},
};
};
The part that fixed it was the ssl: { rejectUnauthorized: false }
line. I just don't understand why ssl must be disabled on Heroku pg...