By default only local processes can connect to PostgreSQL via a file
socket or over the loopback interface. If you intend to expose the
database to the network then additional access needs to be granted.

To add an additional host/network to PostgreSQL’s host-based access
control:

Open /etc/postgresql/9.5/main/pg_hba.conf

Add a line similar to the following but with the appropriate IP
address: