Enabling PostgreSQL Remote Access - PostgreSQL connection only works from local machine
If the PostgreSQL connection is only working locally, make sure
the PostgreSQL instance is configured to allow remote connections.
This involves modifying the pg_hba.conf file by adding
information about the remote ip addresses / hosts that
you want to allow to connect remotely.
Here is an example of how to add specific ip addresses to the
pg_hba.conf file.
host all all 127.0.0.1/32 md5
host all all 192.168.2.2/32 md5
Also make sure that TCP/IP networking is enabled for your
PostgreSQL instance by modifying the postgresql.conf file.
For this, you would want to make sure the listen_addresses line
is pointing to a specific ip address or * instead of localhost. For example,
listen_addresses='*'