Possibly this is a firewall problem, or possibly the PostgreSQL server
is just not configured to accept remote connections from your machine.
When you ssh to the machine and then run psql you are essentially just
running locally on the server. If you can run R on the server in the ssh
session then you should be able to access the database on the local
port, just like you are doing with psql. When you create an ssh tunnel
you are just allowing the R session on your machine to bypass the
PostgreSQL configuration and pretend it is a localhost connection, for
which the server is listening.
If the server is configured to accept connections from your machine you
should be able to run psql locally, rather than on an ssh connection,
with something like
psql -h myHost -p myPort -U myUser myDB
If you try that I expect you will get the same error you get from R.
There are several possible problems in the server configuration, which
is usually done in a file like /etc/postgresql/x.x/main/postgresql.conf
although the file is set in an initialization file and could be
different. To listen on TCP/IP it needs something like
listen_addresses = '*'
and then there are other settings for hosts/users and authentication
methods for users, etc.
If you cannot get the database administrator to adjust the settings for
you, then you will probably need to bypass those settings by using the
ssh tunnel.
Paul
On 02/20/2014 07:28 PM, Neil Tiffin wrote:
> Most likely there is a firewall not that is not allowing access to the
> PostgreSQL data base port on the remote host.
>
> Try creating an SSH tunnel for the PostgreSQL port, for example
> something like:
>
> ssh -L 63333:localhost:myPort myUser@myHost
>
> Then connect in a different local terminal session from R using
> 'localhost' with port 63333. Of course 63333 can be any unused port.
>
> Neil
>
> On Feb 20, 2014, at 4:06 PM, Diego Forteza <
diegof...@gmail.com
>> <mailto:
rpostgresql-d...@googlegroups.com>.