Connection Failed: Error
Connection failed: connection to server at "192.168.*.*", port 5432 failed: FATAL: no pg_hba.conf entry for host "10.0.4.1", user "Help-Desk", database "Help-Desk-Stg", no encryption
Step 1: Edit pg_hba.conf
pg_hba.confGo to the PostgreSQL data directory. By default, it’s usually here:
C:\Program Files\PostgreSQL\<version>\data\(replace
<version>with your installed version, e.g.15).Open
pg_hba.confin Notepad (Run as Administrator).Add a new line at the bottom to allow your client
10.0.4.1:host Help-Desk-Stg Help-Desk 10.0.4.1/32 scram-sha-256If you want to allow all
10.0.4.xclients:host Help-Desk-Stg Help-Desk 10.0.4.0/24 scram-sha-256Or allow all IPs (not secure, only for testing):
host Help-Desk-Stg Help-Desk 0.0.0.0/0 scram-sha-256
Step 2: Edit postgresql.conf
postgresql.confIn the same folder, open
postgresql.conf.Look for this line:
#listen_addresses = 'localhost'Change it to:
listen_addresses = '*'(removes the
#and sets it to allow all IPs).
Step 3: Restart PostgreSQL Service
Press Win + R, type
services.msc, and press Enter.Find PostgreSQL <version> in the list.
Right-click → Restart.
Step 4: Test Connection
From your client machine, run:
psql -h 192.168.*.* -U Help-Desk -d Help-Desk-StgEnter the password for Help-Desk.
REFERENCES
Last updated
Was this helpful?