Saturday, 15 April 2017

error: password authentication failed for user "myuser"

If I have a record in /etc/postgresql/9.4/main/pg_hba.conf which specifically trusts my specific user

# TYPE  DATABASE        USER            ADDRESS                 METHOD
local   all             myuser                                trust

Since I'm on debian I restart postgresql like this

sudo /etc/init.d/postgresql restart

Here is my entire source file testing this out:

const pg = require('pg');
const connectionString = "postgres://myuser:mypassword@localhost/mydbname";

const client = new pg.Client(connectionString);
client.connect();
const query = client.query('SELECT * FROM USERS');
query.on('end', () => { client.end(); });

and this is the error I consistently get:

error: password authentication failed for user "myuser"
    at Connection.parseE (/home/myuser/webserver/node_modules/pg/lib/connection.js:539:11)
    at Connection.parseMessage (/home/myuser/webserver/node_modules/pg/lib/connection.js:366:17)
    at Socket.<anonymous> (/home/myuser/webserver/node_modules/pg/lib/connection.js:105:22)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at TCP.onread (net.js:551:20)

What am I doing wrong here?



via Mathieu Bertin

No comments:

Post a Comment