Search code examples
postgresqlherokuheroku-postgresheroku-cli

Unable to establish a psql session with remote heroku database


I have a remote heroku database ('hobby' tier) and want to establish a remote psql connection but when I type:

heroku pg:psql

I am receiving the following error:

psql: could not connect to server: Operation timed out
    Is the server running on host "ec2-54-163-230-199.compute-1.amazonaws.com" (54.163.230.199) and accepting
    TCP/IP connections on port 5432?

I've edited postgresql.conf such that

listen_addresses = '*'

and added the line:

host all all 0.0.0.0/0 md5

to pg_hba.conf as I thought the issue may be my postgres configuration only accepting connections to localhost, but having restarted Postgres I am still getting the same error.

Anyone have any advice on what may be going wrong? If my firewall is blocking this would anyone have any advice on how to change that? Thanks in advance.


Solution

  • There must be network restrictions or firewall settings as it should work without making changes to conf file.