node-postgres: Connection intermittently made, rejects connection with password authentication failure notice
OSX 10.11.4 PG 9.4.8 Using pg module.
var pg = require('pg');
var conString = "postgres://postgres:REDACTED@localhost/testDb";
pg.connect(conString, function(err, client, done) {
if(err) {
return console.error('error fetching client from pool', err);
}
client.query('SELECT $1::int AS number', ['1'], function(err, result) {
//call `done()` to release the client back to the pool
done();
if(err) {
return console.error('error running query', err);
}
console.log(result.rows[0].number);
//output: 1
});
});
I get the following error:
error fetching client from pool { error: password authentication failed for user “postgres”
Then if I run this code with node - say - 10-15 times, it’ll work once out of those attempts.
I’ve reinstalled postgres and made sure the passwords match. I tried performing an alter user for the password. I tried killing all open connections with pg_terminate_backend(pid). Still fails. Any help would be appreciated. Everything was working with this prior to upgrading to El Capitan, is El Capitan not supported?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (7 by maintainers)
it work after adding this host all all 0.0.0.0/0 md5 in pg_hba.conf file.