PostgreSQL migration issue in AWS RDS with Drizzle ORM: 'no pg_hba.conf entry for host' error

I've been using drizzle for a new project over the past few weeks, and it has provided a great developer experience. Now, it's time to bring the app to production. However, I'm currently facing an issue with the migrations. The app is deployed in AWS ECS and connects to a PostgreSQL database in AWS RDS. I have provided the necessary IAM policies in the ECS task role to access the RDS instance. The connection is established but after that when I execute the migrate function, I'm encountering an error that I didn't experience while running locally.
PostgresError: no pg_hba.conf entry for host <MY_EC2_IP>, user <MY_USER>, database <MY_DATABASE>, no encryption
at ErrorResponse (/app/node_modules/postgres/cjs/src/connection.js:771:26)
at handle (/app/node_modules/postgres/cjs/src/connection.js:473:6)
at Socket.data (/app/node_modules/postgres/cjs/src/connection.js:314:9)
at Socket.emit (node:events:513:28)
at Socket.emit (node:domain:489: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)
PostgresError: no pg_hba.conf entry for host <MY_EC2_IP>, user <MY_USER>, database <MY_DATABASE>, no encryption
at ErrorResponse (/app/node_modules/postgres/cjs/src/connection.js:771:26)
at handle (/app/node_modules/postgres/cjs/src/connection.js:473:6)
at Socket.data (/app/node_modules/postgres/cjs/src/connection.js:314:9)
at Socket.emit (node:events:513:28)
at Socket.emit (node:domain:489: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)
I tried changing postgres client. I had never experienced such issue when using other ORMs like Prisma and TypeORM. Is this something specific to how Drizzle executes SQL in Postgres?
3 Replies
kazdegroot
kazdegroot2y ago
https://www.postgresql.org/docs/current/auth-pg-hba-conf.html < Seems like postgres is unable to auth using your credentials, and is trying to fall back to this. So you have some actual code of you setting up the connection? I think both pg.pool and postgres.js only (try to) connect when a first query is done, so this is probably still a connection error
PostgreSQL Documentation
21.1. The pg_hba.conf File
21.1. The pg_hba.conf File Client authentication is controlled by a configuration file, which traditionally is named pg_hba.conf and is stored in …
quitelistener
quitelistener17mo ago
i am facing same issue. Switched to prisma and my queries are running fine. Drizzle works for migration but queries are failing
pandareaper
pandareaper17mo ago
This will be an SSL issue, there are extra steps to add the root certificates from RDS in order to allow connections to be verified. See a related thread with details on how to configure SSL https://discord.com/channels/1043890932593987624/1128455867021398087/1141231166754664509
Want results from more Discord servers?
Add your server