Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL password authentication failed for user "user"

I have tried to Google this question for a long time now, and I do not seem to get to a solution.

I have downloaded PostgreSQL on Windows, and therefore have a user with username: postgres and password: postgres.

I have no problem with connection using the command line: psql -U postgres.

The problem is when I try to just log in through psql or by using an api with npm run start. I tried setting PG_URL=postgres://postgres:postgres@localhost/postgres, since I am using it in this api.

I then get the error message: psql: FATAL: password authentication failed for user "username on my windows computer".

I have not used my username on the computer at all when setting up this database or server, so I do not know what to do. And when I try to log in through psql none of the password I can think of is correct.

This is how the pgAdmin4 page looks like

like image 435
marasva Avatar asked Jun 20 '26 22:06

marasva


1 Answers

Faced the exact same problem and the answer provided here solved it solution. Just run set PGUSER=postgres in the command prompt and the next time u run psql the password you enter for username=postgres should work.

like image 183
Ray Avatar answered Jun 23 '26 15:06

Ray