Error while creating a connection in RPostgreSQL Package



I am getting following error even after providing usernames, passwords using the following command

Error in postgresqlNewConnection(drv, …) :
RS-DBI driver: (could not connect on dbname “anhffp01”

con <- dbConnect(drv, host=“server”, port=‘port’, dbname=‘anhffp01’,user=Username, password=Pwd)

How to fix the above issue?


Hi @Surya1987

the port seems wrong it is a string with number normally did you check with for example pgAdmin that it is the right port? Or your Db server is not up but this would be surprising

Hope this help.



I put the port number as both Numeric and Character. Neither of the case worked.


I had given the wrong password due to which it was not working properly


oh oh this could happen