How to fix an error: password authentication failed for the user in PostgreSQL

Hassan Al Najjar
2 min readJul 24, 2020

I have two solutions for this Error.

First solution :

open Terminal and write this command in the terminal

sudo editor /etc/postgresql/<postgresql version >/main/pg_hba.conf
  • you can click Tab , if you didn’t know PostgreSQL version

Then, go to the bottom of the file you just played and edit these lines
- if scroll didn’t work you can use keyboard buttons to scroll down

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
  • you must change peer and md5 to trust to be as this
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32…

--

--

Hassan Al Najjar
Hassan Al Najjar

Written by Hassan Al Najjar

Full Stack JS, React Native, Flutter :)

Responses (2)