I try to connect to rds postgresql version 12 from nodeJs as mentioned below. It works completely fine without any issue.
const config = { user: process.env.PG_DB_USERNAME, password: process.env.PG_DB_PASSWORD, database: process.env.PG_DB_NAME, host: process.env.PG_DB_HOST, port: process.env.PG_DB_PORT, } const pool = new Pool(config)
When we use postgresql version 15.2 ton connect from node Js we ended up facing the below error.
Error
{"length":181,"name":"error","severity":"FATAL","code":"28000","file":"auth.c","line":"543","routine":"ClientAuthentication","level":"error","timestamp":"2023-06-19T14:13:33.294Z"}
[ERROR] error: no pg_hba.conf entry for host "XXXXX", user "test", database "testdb", no encryption
at Parser.parseErrorMessage (/usr/src/app/node_modules/pg-protocol/dist/parser.js:287:98)
at Parser.handlePacket (/usr/src/app/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/usr/src/app/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket.<anonymous> (/usr/src/app/node_modules/pg-protocol/dist/index.js:11:42)
at Socket.emit (node:events:526:28)
at Socket.emit (node:domain:475:12)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
at TCP.callbackTrampoline (node:internal/async_hooks:130:17)
I tried passing the below params as suggested in various stack overflow links, but ended with same error.
We tried deploying the code as suggested in the below link , but it's not resolved.
Reference: Node.js, PostgreSQL error: no pg_hba.conf entry for host
"dialectOptions": { "ssl": true }
ssl: true
Could you please help in fixing this error?