This happens even when the DB user specified in .env file is different. For the record "ankitj" is also the username of my system. I don't understand why this is happening.
Here's the error:
Unhandled rejection SequelizeConnectionError: password authentication failed for user "ankitj"
at connection.connect.err (/home/ankitj/Desktop/skillbee/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:128:24)
at Connection.connectingErrorHandler (/home/ankitj/Desktop/skillbee/node_modules/pg/lib/client.js:140:14)
at Connection.emit (events.js:160:13)
at Socket.<anonymous> (/home/ankitj/Desktop/skillbee/node_modules/pg/lib/connection.js:124:12)
at Socket.emit (events.js:160:13)
at addChunk (_stream_readable.js:269:12)
at readableAddChunk (_stream_readable.js:256:11)
at Socket.Readable.push (_stream_readable.js:213:10)
at TCP.onread (net.js:599:20)
I'm assuming that you're getting this error using Sequelize with Node.js. I ran into the same error when I had the following:
const sequelize = new Sequelize(
process.env.DATABASE,
process.env.DATABASE_USER,
process.env.DATABASE_PASSWORD,
{
dialect: 'postgres',
}
)
I was able to solve the issue by replacing it with a connection ur:
const sequelize = new Sequelize("postgres://postgres:postgres@localhost/gql", {
dialect: 'postgres'
// anything else you want to pass
})
where gql
is the name of DATABASE
in my .env
file.
The user "ankitj" executes the command to run the Node script, so the script is trying to connect as that user. I first tried to solve this on the Postgres end by adding a user and granting permissions, but was unable to get that to work--I'd be interested in seeing that solution--but specifying a connection url worked for me.
I had the same issue when I was using the default password for the PostgreSQL. Try to change it from the command line as follows.
psql
\password
Then Enter a new password and update your .env
files and that should Work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With