I'm trying to connect to my database using postgres on docker but it says that the password authentication failed.
My code:
const { Client } = require('pg');
const client = new Client({
host: 'localhost',
port: 5432,
user: 'root',
password: 'root',
database: 'mycontacts',
});
client.connect();
docker command to start the postgres container:
docker run --name postg -e POSTGRES_USER=root2 -e POSTGRES_PASSWORD=root2 -p 5432:5432 -d postgres
Try creating another Postgres container to try and connect and it will work. Else. password authentication failed while trying to connect into my docker database
It ended up being the postgres that i had installed on my pc.
I uninstalled it and now its working!