PostgreSQL remote connection

This arcticle was writen based PostgreSQL version 10.10 and running on Ubuntu 18.04

Configuring postgresql.conf

Find postgresql.conf

$ find / -name "postgresql.conf"
/usr/lib/tmpfiles.d/postgresql.conf
/etc/postgresql/10/main/postgresql.conf

Open file /etc/postgresql/10/main/postgresql.conf and replace line

listen_addresses = 'localhost'

with

listen_addresses = '*'

Configuring pg_hba.conf

Open file /etc/postgresql/10/main/pg_hba.conf and add following entry at the very end

host    all             all     0.0.0.0/0                    md5
host    all             all     ::/0                         md5

Do not get confused by “md5” option mentioned above. All it means is that a password needs to be provided. If you want client to allow collection without providing any password then change “md5” to “trust” and that will allow connection unconditionally.

Restart postgresql server.