R and PostgreSSQL error


Tried to connect R with PostgresSQL but it failed throwing error. Not able to figure out the exact issue.

Executed Script -

con < dbConnect(pg,user="rasao",password="1281",host="localhost",port=5432, dbname="banking_case")

"Error in postgresqlNewConnection(drv, ...) :
RS-DBI driver: (could not connect rasao@localhost:5432 on dbname "banking_case": FATAL: password authentication failed for user "rasao"


This error doesn't make it more clear? Are you sure your password is correct?


To connect to PostgreSQL database the username is rasao and password is 1281.

I am entering the same password, but R is throwing error authentication failed for user rasao.

Is there any other way to connect R to PostgreSQL database?


Not 100% confident, but I believe I've run into this issue recently, and got around it by putting the credentials into a .pgpass file. Try following this guide


If you are currently using dbplyr or RPostgresSQL,

try this package:


Not 100% sure if this is the best way to do it, but I use a .ini file and then use gsub to extract the credentials. I would also recommend the RPostgres package to connect. Here's a quick example I spun up a while ago.


Thank you so much for the info