4

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

Rastalamm
  • 1,712
  • 3
  • 23
  • 32
marasva
  • 53
  • 6
  • 2
    Struggling with the same issue — have you been able to figure out the cause? – Bart Feb 16 '18 at 16:24
  • Realizing this is almost two years later -- were you ever able to solve this problem? One thing that jumps out is that the working option `psql -U postgres` omits a password; depending on your pg_hba.conf configuration, your server could be set up to reject password based authentication, but allow other authentication methods like trust (https://www.postgresql.org/docs/current/auth-pg-hba-conf.html, `auth_method` section). – Adam Bethke Mar 29 '19 at 01:39

1 Answers1

1

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.

Ray
  • 63
  • 2
  • 9