jsstuball
jsstuball

Reputation: 4911

Can't connect remotely to postgres, no response from psql request

Ubuntu 16.04 LTS

I have followed the guides which all say the same thing; to enable remote connection to a postgres server, update the postgresql.conf file, update the pg_hba.conf file and make sure the port (5432) is open and firewall is not blocking.

When I attempt to connect to my server from the remote machine using the following command, I receive no response (for example, 'Connection refused...'). It hangs as if the firewall has DROP policy, but I checked and the host's firewall is ACCEPT all. Here is the command:

psql -h 45.67.82.123 -U postgres -p 5432 -d mydatabase

I have googled extensively and can't find anyone else who's psql request sits with no response from the host server.

Edit: I should mention I have been connecting locally on the host machine. I should also mention that the data directory on the host machine is in a non-default location. I have my cluster on a mounted drive, in case this could affect the remote connection.

Upvotes: 1

Views: 2129

Answers (1)

jsstuball
jsstuball

Reputation: 4911

Solution: It is my first AWS instance and I didn't know they have their own firewall rules on the platform. So I was highly confused by the fact all my policies were ACCEPT on my server. Turns out you are behind AWS firewall and you have to go onto the platform to add/change security groups etc. In the past when I've used Digital Ocean droplets or Linodes, the firewall policy on the vps is all I need to change. AWS threw me another curveball there.

Upvotes: 2

Related Questions