PostgreSQL “no pg_hba.conf entry for host “ user “postgres”, database “postgres”, SSL off”

Poolsawat Apin
1 min readSep 8, 2020

ปัญหา pgAdmin (client tool) ไม่สามารถ connect กับ PostgresSQL Database server ได้

เพิ่ม Client IP ที่ไฟล์ */PostgreSQL/12/data/pg_hba.conf (IP v4)

จากเดิม

# TYPE DATABASE USER ADDRESS METHOD

# IPv4 local connections:
host all all 127.0.0.1/32 md5

แก้ไขเป็น

# TYPE DATABASE USER ADDRESS METHOD

# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all {client ip}/24 md5 #เพิ่ม client ip ใหม่

แก้ไขไฟล์ PostgreSQL/12/data/postgresql.conf

จากเดิม

#listen_addresses = ‘localhost’

แก้ไขเป็น

listen_addresses = ‘*’

จากนั้น restart postgresql service แล้วลอง pgAdmin ต่อมาอีกครั้ง ก็จะ connected remote host ได้เรียบร้อย

--

--

Poolsawat Apin

Senior Engineering, Full Stack Developer [Subscribe Me @poolsawat.com]