Cannot connect to Postgres database from RStudio but can connect from DBeaver and psql

140 Views Asked by At

Can connect to the database from psql and DBeaver but when using RpostgreSQL package in RSudio I receive the following error:

RPosgreSQL error: could not connect user@hostname on dbname "database": FATAL: no pg_hba.conf entry for host "", user "user_name", database "databse", SSL off

Macbook Pro '21, M1, macOS Monterey

Here is my code:

tryCatch({
    drv <- dbDriver("PostgreSQL")
    print("Connecting to Database…")
    connec <- dbConnect(drv, 
                 dbname = dsn_database,
                 host = dsn_hostname, 
                 port = dsn_port,
                 user = dsn_uid, 
                 password = dsn_pwd)
    print("Database Connected!")
    },
    error=function(cond) {
            print("Unable to connect to Database.")
    })
0

There are 0 best solutions below