0

I'm getting an authorization error when trying to connect to my postgres database through localhost. I can log in fine with sudo -u postgres psql. When trying to connect through my Express application (using both Sequelize and node-postgres) I get an error.

error:

error: password authentication failed for user: "postgres"

.env:

PGUSER="postgres"
PGHOST=""
PGPASSWORD=""
PGDATABASE=""
PGPORT=""

sequelize config:

const sequelize = new Sequelize('postgres://postgres@localhost:5432/test', { ... });

I've edited my pg_hba.conf file, as well to accept all localhost connections with:

local all all _BLANK_ trust
  • Possible duplicate of [Postgresql: password authentication failed for user "postgres"](https://stackoverflow.com/questions/7695962/postgresql-password-authentication-failed-for-user-postgres) –  Oct 30 '19 at 20:03
  • 1
    Did you reload PostgreSQL? – Laurenz Albe Oct 30 '19 at 21:34
  • Did you also run your nodejs application with `sudo -u postgres`? – Bergi Oct 30 '19 at 22:03
  • Yes, PostgreSQL has been restarted with both `sudo systemctl restart postgres.service` and another restart command that I can't remember right now. – mbyucki Oct 31 '19 at 14:59
  • @Bauke THAT WORKED! Thank you, specifically the second answer. Sorry I hadn't seen that question before. – mbyucki Oct 31 '19 at 15:10

0 Answers0