Issue Connecting to PostgreSQL Locally: FATAL: password authentication failed for user

154 Views Asked by At

I'm facing an issue when trying to connect to a locally running PostgreSQL server. I've set up the server using Docker, and despite following the steps, I'm getting the error "FATAL: password authentication failed for user 'root'." Here are the details of my setup:

  1. Docker Command:
    docker run -it \
      -e POSTGRES_USER="root" \
      -e POSTGRES_PASSWORD="root" \
      -e POSTGRES_DB="ny_taxi" \ 
      -v c:/Users/LENOVO/Data_engineering_zoomcamp1/
         2_docker_sql/ny_taxi_postgres_data2:
         /var/lib/postgresql/data \
      -p 5432:5432 \
      postgres:16
    
    
    

**Connection attempt: **

  • Tool: pgcli
  • Command: pgcli -h localhost -p 5432 -U root -d ny_taxi

Observations

  • I've ensured that the PostgreSQL container starts successfully, and the server logs indicate that it's ready to accept connections.
  • The password I'm entering matches the one set during the container setup.

I used several troubleshooting

  • Checked Docker logs (docker logs hopeful_brown) for any errors.
  • Verified PostgreSQL user and password.
  • Attempted connection using psql with the same result.

Additional Information:

  • Operating System: Windows 11
  • Docker Version: 24.0.6
  • PostgreSQL Version: 16.1
0

There are 0 best solutions below