-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Connection intermittently made, rejects connection with password authentication failure notice #1018
Comments
Also tried altering the connection string to postgres://[username]:[password]@[host]:[port]/[databasename] format with no avail by adding the 5432 port which I confirmed via pgadminIII it is using. |
do you connect to postgres from command line simply by typing |
And if I write this code, I will write it as this: var pg = require('pg');
var conString = 'postgres://postgres:REDACTED@localhost/testDb';
pg.connect(conString, function(err, client, done) {
if (err) {
console.error('error fetching client from pool', err);
return done && done(err); // not sure...
}
client.query('SELECT $1::int AS number', [1], function(err, result) {
if (err) {
console.error('error running query', err);
return done(err);
}
console.log(result.rows[0].number);
//output: 1
done();
});
}); |
I tried the above code, I get the same error message. I am able to connect to psql via pgadminIII and the SQL shell without any problem. What is weird to me is the fact that if I run this code 20 times or so, it'll eventually work but on every other attempt it says error fetching client from pool { error: password authentication failed for user "postgres" |
Here is the output from the console:
then just so happens on my 10th try this time:
I get the correct output. Why would it work some of the time and not others? I am beginning to think this is not a password issue because I am not changing anything in the connection string or the code. I am just executing it again and again until it works.... |
weird.. try install pg-native and Try to change password, then create new user with different password... I have my own wrapper here using this in background but not experiencing trouble.. You can also try @vitaly-t library |
I'll give that a try and report back to you on my findings |
Going sleep, good luck |
I am able to get pg-native to work, I am hoping though for a solution in which I am able to use the regular pg library as I do not want to have to re-write a large project to use pg-native. Any suggestions on the above issue? Due to the fact that pg-native works, the sql-shell works, and pgadminIII works, I am venturing the issue lies with the pg-module? |
One doesn't really have to change anything when switching over to To your original problem - which versions of Node.js and |
I am using 6.x for node. It looks like the pg module I am using may be older and does not have this update. I'll update pg to see if that fixes the issue as the issue you linked to seems very similar to what I am experiencing. Thanks! |
I am also seeing this intermittent "password authentication failed for user..." error, starting as of a few days ago. About 1 in 10-20 attempts succeed, and the rest fail with this error. I am seeing it with the I am on node 6.1. We've had the database running for several years, and the credentials have not changed. Other tools and our apps are able to connect fine (psql, Postico, pgAdmin3, etc.). Edit: sorry, looking at your #1000 issue, I will try updating pg to at least 4.5.5 to try the |
- There is a change in `Buffer` in node 6 that causes an issue with authentication in the `pg`/`pg.js` modules. - See brianc/node-postgres#1018 - Which references: brianc/node-postgres#1000 - This commit changes the pg library dependency to the version that contains the fix for this issue.
Looks like there might have been some confusion around versions & upgrading with node & pg versions - please feel free to open a new issue if this isn't fixed but AFAICT this looks like it's been resolved in y'all's environments? Sorry for any headache this has caused! |
@traegerp : I am facing same problem. out 15-10 times one time i am able get data from Postgres db . how did you resolve this ... |
it work after adding this |
@FarhanAhmad212 This is very bad. You should try more secure way. |
I encountered intermittent password authentication failure today, and it was due to my hostname resolving to multiple IPs with different databases (and different username/passwords). While debugging I used Not sure if this was the OP's issue and I know this issue is old but I'm just messaging here as it might help someone debug if they ever find a similar situation. |
OSX 10.11.4
PG 9.4.8
Using pg module.
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?
The text was updated successfully, but these errors were encountered: