skip to Main Content

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

2

Answers


  1. Chosen as BEST ANSWER

    It ended up being the postgres that i had installed on my pc.

    I uninstalled it and now its working!


  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search