CONNECT
Grant privilege CONNECT
# GRANT CONNECT ON DATABASE dbname TO username;
And add privilege on the schema (in this example public):
# GRANT USAGE ON SCHEMA public TO username;
You can find this file in /etc/postgresql/12/main/postgresql.conf
(for postgres version 12).
After that edit listen_addresses
listen_addresses = 'localhost'
listen_addresses = '*'
You can find this file in /etc/postgresql/12/main/pg_hba.conf
(for postgres version 12).
After that add this lines:
host all all 0.0.0.0/0 md5
host all all ::/0 md5
If you are started postgres as a cluster:
pg_ctlcluster 12 main restart