1

I have created a new database and user in Postgresql 10 named 'reportingdashboardproject' and 'repadmin' respectively. I used the following commands to create and grant privileges:

postgres=# create database reportingdashboardproject;
postgres=# create user repadmin with encrypted password '<password>';
postgres=# grant all privileges on database reportingdashboardproject to repadmin;
psql=# grant all privileges on database reportingdashboardproject to repadmin ;

I get this in response when trying to start my Express.js server with a db connection URI using the above:

FATAL password authentication failed for user repadmin

Here is the relevant code:

const dbConfig = {
  operatorsAliases: false
};

const Sequelize = require("sequelize");
const sequelize = new Sequelize('postgres://postgres:postgres@localhost:5432/reportingdashboardproject', dbConfig); //also tried using repadmin:<password>, failed.

I get the same error when trying to open the connection through DBeaver (port 5432)

I then tried using user: postgres and password: postgres, or empty. None of these combos worked. On the empty password attempt I saw this:

The server requested password based authentication, but no password was provided

Partial Db list (template0 and template1 were there too):

postgres=# \l

  Name            |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
---------------------------+----------+----------+-------------+-------------+-----------------------
 postgres                  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 reportingdashboardproject | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres         +

User list:

postgres=# \du
                                   List of roles
 Role name |                         Attributes                         | Member of 
-----------+------------------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 repadmin  |                                                            | {}

I have tried explicitly granting privileges to the superuser also:

postgres=# grant all privileges on database reportingdashboardproject to postgres;
GRANT

Could it be a sudo/permissions issue of some kind?

postgres=# \q
could not save history to file "/opt/PostgreSQL/10/.psql_history": Permission denied

Not sure what to troubleshoot next. Thanks for any guidance.

EDIT: Adding the following:

Inside /etc/postgresql/10/main/pg_hba.conf I see this:

# 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

# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            md5
host    replication     all             ::1/128                 md5

.

postgres=# select * from pg_authid where rolname='repadmin' \gx
-[ RECORD 1 ]--+------------------------------------
rolname        | repadmin
rolsuper       | f
rolinherit     | t
rolcreaterole  | f
rolcreatedb    | f
rolcanlogin    | t
rolreplication | f
rolbypassrls   | f
rolconnlimit   | -1
rolpassword    | md529562c8706ed74d108795a4e9a37f261
rolvaliduntil  | 
  • Check you pg_hba.conf and the property listen_addreses inside postgresql.conf – Imanol Y. Jan 2 at 16:28
  • #listen_addresses = 'localhost' port = 5433 Tried connecting with port 5433. Same error – Sean Dezoysa Jan 2 at 18:45
  • Yes, on attempts 1 and 2 I entered the passwords. On try 3 I did not: owner@G700:~$ psql -U repadmin -h localhost -d reportingdashboardproject Password for user repadmin: psql: FATAL: password authentication failed for user "repadmin" owner@G700:~$ psql -U postgres -h localhost -d reportingdashboardproject Password for user postgres: psql: FATAL: password authentication failed for user "postgres" owner@G700:~$ psql -U postgres -h localhost -d reportingdashboardproject Password for user postgres: psql: fe_sendauth: no password supplied owner@G700:~$ – Sean Dezoysa Jan 2 at 19:33
  • Ok, done.......... – Sean Dezoysa Jan 2 at 19:45
  • Sorry, it was there but I mis-copied it. It was blank as shown in the post now – Sean Dezoysa Jan 2 at 20:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.