0

I am having trouble connecting to my Amazon RDS PostgreSQL database using R on RStudio and using the package RPostgreSQL.

I am running:

library("RPostgreSQL")

drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, dbname="mydbname", 
                 host="........us-west-2.rds.amazonaws.com", port=5432, 
                 user="myuser", password="mypassword")

After running this line, I get the error:

Error in postgresqlNewConnection(drv, ...) : RS-DBI driver: (could not connect myuser@.........us-west-2.rds.amazonaws.com on dbname "mydbname" )

Note that I have the correct dbname, host, port, user and password because I am able to connect to the Amazon database using pgAdmin3

Here is my session info:

R version 3.3.0 (2016-05-03)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.5 (El Capitan)

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RPostgreSQL_0.4-1 DBI_0.4-1         dplyr_0.4.3       knitr_1.13        rbokeh_0.4.2     
[6] miniUI_0.1.1      shiny_0.13.2     

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.5             formatR_1.4             highr_0.6               pryr_0.1.2             
 [5] plyr_1.8.4              tools_3.3.0             digest_0.6.9            jsonlite_0.9.22        
 [9] evaluate_0.9            gtable_0.2.0            lattice_0.20-33         datasummary_0.2.0      
[13] yaml_2.1.13             parallel_3.3.0          hexbin_1.27.1           httr_1.2.0             
[17] stringr_1.0.0           htmlwidgets_0.6         DistributionUtils_0.5-1 maps_3.1.0             
[21] packagedocs_0.3.6       grid_3.3.0              DT_0.1.56               R6_2.1.2               
[25] rmarkdown_0.9.6.14      ggplot2_2.1.0           gistr_0.3.6             magrittr_1.5           
[29] whisker_0.3-2           scales_0.4.0            codetools_0.2-14        htmltools_0.3.5        
[33] lazyrmd_0.1.0           assertthat_0.1          xtable_1.8-2            mime_0.4               
[37] colorspace_1.2-6        httpuv_1.3.3            stringi_1.1.1           lazyeval_0.2.0         
[41] munsell_0.4.3      
cullan
  • 280
  • 3
  • 13

1 Answers1

2

try to connect using RPostgres package, it worked for me. See details here

Community
  • 1
  • 1
Kasia Kulma
  • 1,683
  • 1
  • 14
  • 39