I have a Node / Express app with a Postgres database that functions perfectly on my local machine, but I'm struggling to get it up and running on Heroku. The problem occurs after I push to Heroku -- which builds successfully -- when I then try to run heroku run sequelize db:migrate
. The error is:
ERROR: self signed certificate
My setup:
- Node v15.12.0
- Postgres database ("Heroku Postgres" add-on)
- pg v8.5.1
- sequelize v6.6.2
- sequelize-cli v6.2.0
My Sequelize connection parameters:
{
"development": {
"username": "XXXXXX",
"password": "XXXXXX",
"database": "party_playlist",
"host": "127.0.0.1",
"dialect": "postgres"
},
"production": {
"use_env_variable": "DATABASE_URL",
"dialect": "postgres",
"dialectOptions": {
"ssl": {
"require": "true",
"rejectUnauthorized": "false"
}
}
}
}
Many posts speak to this issue (GitHub: 1 | 2 | 3, StackOverflow: 1 | 2 | 3), and most point to pg v8 as being the root of the problem; however, none of the recommended solutions have worked for me.
What I've tried so far:
- Adding
rejectUnauthorized: false
to my Sequelize connection params - Adding
ssl:true
to the config outside of dialectOptions - Adding
NODE_TLS_REJECT_UNAUTHORIZED=0
to my Heroku environment variables - Adding
PGSSLMODE=no-verify
to my Heroku environment variables - Toggling Heroku's
Automatic Certificate Management
feature on/off - Rolling back to pg v7 (various subversions)
1-5 have no effect, and rolling back to pg v7 breaks the app (locally, any attempted reads/writes to the database hang with no error message; on heroku, the db:migrate command runs without an error message, but the db isn't updated). I assume that pg v7 is incompatible with my Node version or some other package version in my project, but I have no idea how to figure out what a compatible version set would be other than by trial and error, which isn't feasible. Also, as a side note, this is a hobby project so I'm not worried about MITM attacks.
Interestingly, I'm able to connect to my Heroku database just fine when I run heroku pg:psql
!
Any ideas how I can fix this one? Any and all help would be much appreciated!