-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to connect to Heroku postgres from outside of Heroku #278
Comments
Solution is here. To do so in typeorm you need to provide option in special "extra" section of connection options: createConnection(
driver: {
type: "postgres",
host: "localhost",
port: 5432,
username: "root",
password: "admin",
database: "test",
extra: {
ssl: true
}
},); |
hey sorry old issue, but how do you set this with .env file or env vars? |
You need to set TYPEORM_DRIVER_EXTRA = {"ssl":true} |
thanks it did work |
In my case:
|
I m trying to connect postgresql heroku to oracle sql developer. But i m getting the below error message": "no pg_hba.conf entry for host "xxx", user "xxx", database "xxx", SSL off" what could be the solution? |
@N-CP, what is your |
For me it worked with: createConnection({
url: process.env.DATABASE_URL,
type: 'postgres',
entities: [YOUR ENTITIES GO HERE],
synchronize: true,
+ ssl: true,
}); |
I believe the original issue and the solutions (both JSON & env) has to be documented. Would such pull request for docs website be accepted? |
SSL options are already documented (https://github.com/typeorm/typeorm/blob/master/docs/connection-options.md). However if you find a good place to remind about that(common problem?) PR will be accepted. |
Also PGSSLMODE=require solves this problem. |
worked for me too. |
hi there! const config: PostgresConnectionOptions = {
...baseConfig, // here're common settings
url: process.env.DATABASE_URL, // got from DATABASE_URL config var in Heroku
ssl: true, // double check
extra: {
ssl: true,
},
}; also tried to set up TypeORM in package.json: getting the error: Error: self signed certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1321:34)
at TLSSocket.emit (events.js:210:5)
at TLSSocket._finishInit (_tls_wrap.js:794:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:608:12) {
code: 'DEPTH_ZERO_SELF_SIGNED_CERT'
} not sure what certificate should I use, or can I bypass it somehow? thanks in advance! |
jeez it fails on Heroku as well! UPDATE: sorry, false alarm! it's actually |
I've just run into this issue and it seems that I believe the ideal solution is to get a new SSL certificate, but for now I have:
|
it works for me. Thanks! |
What fixed for me while using Postgres from Heroku was only adding the following environment variable:
|
What worked for me:
|
Yes, this for me also, AND I had to REMOVE:
What a PITA |
When running migrations on DOAP I got the following error: Error during migration run: error: no pg_hba.conf entry for host "134.209.211.49", user "db", database "db", SSL off. This should fix it. See typeorm/typeorm#278
If, like me, you added |
thanks a lot it worked for me too |
Thank you so much for this. I have searched everywhere. All the solutions on this thread did not work for me except this. Thanks again. |
Just as a follow up, since Heroku enforced SSL for all postgres connections the above is the solution they recommend. So I guess it is safe for production. 😊 |
Guys, the issue is in the
|
I resolve my issue by setting This was not a typeorm issue, it's because heroku use self signed certificates. |
In order to connect to Heroku postgres from outside of Heroku we need to use SSL.
So, I'm getting the following message when trying to connect typeorm to the Heroku postgres.
I believe this is happening because the postgres driver is trying to connect without SSL. If I'm correct, how can I tell the sql driver to use SSL.
The text was updated successfully, but these errors were encountered: