Heroku PostgreSQL connection problem
See original GitHub issueTrying to do something similar to #47 (connect to postgres database on heroku). I tried to set up my connection config with the host, user, password, and database name from the $DATABASE_URL environment variable.
I’ve tried both the EC2 url and the IP address as the host.
When I set up the model node and call save, the record should be saved to the database. When I connect to psql
via heroku pg
and query the users table it’s empty.
The example uses Bookshelf. Let me know if I should file the issue under that repo. Although my understanding is that the connection config just gets passed to Knex.
var Bookshelf = require( 'bookshelf' );
Bookshelf.PG = Bookshelf.initialize({
client: 'pg',
debug: true,
connection: {
host : process.env.PG_HOST || 'localhost',
user : process.env.PG_USER || 'postgres',
password : process.env.PG_PASSWORD || 'postgres',
database : process.env.PG_DB || 'db',
charset : 'utf8'
}
});
var User = Bookshelf.PG.Model.extend({
tableName: 'users',
idAttribute: 'id'
});
var u = User.forge({email: 'test@fake.com', password: 'test'});
u.save();
Issue Analytics
- State:
- Created 9 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Why am I seeing connection errors for my Heroku Postgres ...
These errors indicate a failed login attempt was made to your database, which means that the connection wasn't established. It is common to...
Read more >HEROKU POSTGRES error: Connection refused Is the server ...
It could be a problem with the proxy or firewall of the internet connection you are using. Try to connect ...
Read more >Can't connect to Heroku PostgreSql : DBE-5662 - YouTrack
Can't connect to Heroku PostgreSql using params shown in attached files. Getting error: Connection to Heroku failed.
Read more >Heroku Postgres Connection - Salesforce Help
Create a remote connection using the Heroku Postgres connector to sync Heroku Postgres data to CRM Analytics. ... To access Heroku Postgres in...
Read more >Connection to Postgres on Heroku with Go - Google Groups
Has anyone successfully connected to Heroku's Postgres using a Go app? I am getting a consistent error: dial tcp 127.0.0.1:5432: connection refused.
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
I ended up here struggling with wierd connection errors on Heroku. My issue was that the connection string given by Heroku doesn’t have “?ssl=true” in the end even though Heroku requires it. This can be solved by “heroku config:set PGSSLMODE=require” which will tell the pg adapter to use SSL if the config doesn’t say anything about it. It could be the case that pg.Client and pg.connect doesn’t behave completely the same.