To enable remote access to a postgresql database from a computer or server, in Ubuntu server, first we need to know the ip of the computer in question, for example 220.127.116.11.
Then, from the terminal, enter the directory where postgresql is installed:
open edit pg_hba.conf:
sudo nano pg_hba.conf
and add the following line:
host all all 18.104.22.168 trust
Finally, edit the postgresql.conf file in the same directory as follows:
listen_addresses = '*'
Once saved, you must restart postgresql:
sudo service postgresql restart