FATAL no pg_hba.conf entry for host "", user "postgres", database "postgres", no encryption
Remote connection errors are usually related to PostgreSQL permission settings. It is important to carefully review these connection permissions.
After installing PostgreSQL, you should make the necessary configurations:
- Firewall Rules: Make sure the port that PostgreSQL is listening on (usually
5432
) is open. - Network Connections: Set which IP addresses can connect in the
pg_hba.conf
file. - User Roles/Permissions: Make sure that the users who will be connecting have sufficient permissions.
------Linux:
File: /etc/postgresql/10/main/pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
host all all 0.0.0.0/0 md5
host marketdb faruk 0.0.0.0/0 md5 (spesific ip, user etc.)
File: /etc/postgresql/12/main/postgresql.conf
listen_addresses = '*'
Firewall Rules:
ss -nlp | grep 5432
ufw status verbose
sudo ufw allow 5432
------Windows:
File: C:\Program Files\PostgreSQL\xxxxx\data\pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
host all all 0.0.0.0/0 md5
host marketdb faruk 0.0.0.0/0 md5 (spesific ip, user etc.)
File: C:\Program Files\PostgreSQL\xxxxx\data\postgresql.conf
listen_addresses = '*'
Firewall Rules:
netstat -a | grep 5432
Windows Firewall -> Advanced Settings -> New Rule:
#Default 'postgres' user password change:
sudo -u postgres psql
ALTER USER postgres WITH PASSWORD 'passwd12345';
\q
#PostgreSQL Users Perm Configuration: [*for SUPERUSER]
\du
\l+
ALTER USER postgres WITH SUPERUSER;
ALTER USER faruk WITH SUPERUSER;
#Service restart:
systemctl restart postgresql [Linux]
service postgresql restart [Windows]
Wait! there is another more way
This post is licensed under CC BY 4.0 by the author.