Cannot run in heroku with SSL on
See original GitHub issueI am using standard Postgres in Heroku, which has SSL on by default. Whenever I try to run the migrations, I get hit with:
[ERROR] error: no pg_hba.conf entry for host "${ip}", user "${user}", database "${database}", SSL off
at Connection.parseE (/app/node_modules/db-migrate-pg/node_modules/pg/lib/connection.js:539:11)
at Connection.parseMessage (/app/node_modules/db-migrate-pg/node_modules/pg/lib/connection.js:366:17)
at Socket.<anonymous> (/app/node_modules/db-migrate-pg/node_modules/pg/lib/connection.js:105:22)
at emitOne (events.js:96:13)
at Socket.emit (events.js:191:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:563:20)
My migration command:
package.json:
"migrate": "db-migrate --config migrations-config.js",
"migrate-up": "npm run migrate up"
My migrations-config: ‘use strict’
import {postgres} from 'config'
import {parse as urlParse} from 'url'
const parsed = urlParse(postgres.connectionUrl)
const auth = parsed.auth.split(':')
const user = auth[0]
const password = auth[1]
export default {
driver: 'pg',
user,
password,
host: parsed.hostname,
database: parsed.pathname.substring(1),
port: parsed.port,
schema: '${schema}',
ssl: (process.env.NODE_ENV === 'production')
}
and my config.js entry:
export const postgres = {
connectionUrl: process.env.DATABASE_URL
}
If I change the ssl to be explicitly true via:
ssl: true
``` in the migrations config, the result is the same.
Any suggestions on how to fix this would be amazing!
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
Heroku SSL
SSL is a cryptographic protocol that provides end-to-end encryption and integrity for all web requests. Enable SSL on apps that transmit ...
Read more >SSL Error on Heroku app - Stack Overflow
I cannot get ssl to work properly on my heroku app. I have successfully add the crt key witch gives me: Resolving trust...
Read more >Installing an SSL certificate on Heroku SSL - Hosting
Please keep in mind that for Heroku, it's necessary to combine the certificate and the CA Bundle into one file. You can open...
Read more >Troubleshooting Heroku SSL errors - DNSimple Help
This server could not prove that it is www.alpha.com; its security certificate is from www.bravo.com. This may be caused by a misconfiguration or...
Read more >How to Install an SSL Certificate on Heroku?
Via Heroku Dashboard · Open the Certificate · Select the necessary application from the list, then select Settings · Scroll down the page...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For others coming here at a later time, this is what helped me.
I am using a
database.json
file as the default configuration. Turns out Heroku already offers a default JSON config for the database, so in the particular environment you are running the app in, all you need to add is this:rejectUnauthorized
is the key element here.Thanks @shto, you solved my problem!
Just to be overly clear for people who are bad at reading the docs (as myself). You have to pass in the explicit env you defined in your
database.json
when running the migration, e.g.: