0

I created an Elastic Beanstalk with a Nodejs app on it. Then from the environments' configurations I created a postgres RDS.

I can connect to the postgres server from a console:

psql --host=aa1682linxrnijl.c09xht5iw0ld.us-east-1.rds.amazonaws.com --port=5432 --username=monolithDB --password --dbname=postgres 

And I also have an existing table in it. result of \dt

But when I try to connect from my Nodejs localhost, using node-postgres:

const { Client } = require("pg");
const client = new Client({
  host: 'aa1682linxrnijl.c09xht5iw0ld.us-east-1.rds.amazonaws.com',
  password: 'XXX',
  port: 5432,
  database: 'postgres',
  user: 'monolithDB'
});

client.connect()

I get an error:

error: role "root" does not exist

It seems to me that the node-postgres doesn't recognize the 'monolithDB' as a user. How can I properly connect to the Postgres server?

youhatch
  • 141
  • 3
  • 7
  • Does this answer your question? [PostgreSQL error: Fatal: role "username" does not exist](https://stackoverflow.com/questions/11919391/postgresql-error-fatal-role-username-does-not-exist) – Adiii Jul 18 '20 at 10:50
  • 1
    Or change the user `monolithDB` from this to `postgress` as you are using default database. – Adiii Jul 18 '20 at 10:52
  • Try changing the password and use a simple password without any special characters. I faced a similar issue when I was using a connection string/url to connect to RDS postgres. Changing the password fixed the issue for me. – Yousuf Khan Jul 18 '20 at 11:18

0 Answers0