RPostgreSQL cannot connect to the server
<p>I'm trying to access a PostgreSQL database through R.
I tried the following code:</p>

<pre><code>   library(RPostgreSQL)
   library(DBI)

   drv &lt;- dbDriver("PostgreSQL")

   con = dbConnect(drv, #constructs SQL driver
                   host = MyHost, 
                   port = MyPort,
                   dbname = MyDbname,
                   user = MyUser,
                   password = pw)
</code></pre>

<p>I already have PostgreSQL installed on my computer. 
With all my credentials being correct, I still get this Error:</p>

<pre><code> Error in postgresqlNewConnection(drv, ...) : 
     RS-DBI driver: (could not connect [MyUser]@[MyHost] on MyDbname 
</code></pre>

<p>any ideas what causes the problem? <a href="https://stackoverflow.com/questions/38056641/cannot-connect-to-amazon-postgresql-rds-database-on-r-using-rpostgresql">The same problem here</a>  has no solution yet. Thanks for your help</p>

<pre><code>   &gt; sessionInfo()
   R version 3.3.1 (2016-06-21)
   Platform: x86_64-apple-darwin13.4.0 (64-bit)
   Running under: OS X 10.11.6 (El Capitan)
</code></pre>

<p>Kasia</p>