From: https://opensource.com/article/17/10/set-postgres-database-your-raspberry-pi
'''
-
Edit the PostgreSQL config file /etc/postgresql/9.6/main/postgresql.conf to uncomment the listen_addresses line and change its value from localhost to *. Save and exit.
-
Edit the pg_hba config file /etc/postgresql/9.6/main/pg_hba.conf to change 127.0.0.1/32 to 0.0.0.0/0 for IPv4 and ::1/128 to ::/0 for IPv6. Save and exit.
-
Restart the PostgreSQL service: sudo service postgresql restart.