porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.09k stars 259 forks source link

TLS issue on Fly.io + AWS RDS Postgres #763

Open scraper095 opened 7 months ago

scraper095 commented 7 months ago

Hi, I have a Remix app with AWS RDS Postgres as my managed DB with SSL enabled. My application works locally perfectly, but unfortunately when deploying I get these errors:

2023-12-21T09:35:34.850 app[] ams [info] Error: Client network socket disconnected before secure TLS connection was established

2023-12-21T09:35:34.850 app[] ams [info] at connResetException (node:internal/errors:720:14)

2023-12-21T09:35:34.850 app[] ams [info] at TLSSocket.onConnectEnd (node:_tls_wrap:1714:19)

2023-12-21T09:35:34.850 app[] ams [info] at TLSSocket.emit (node:events:529:35)

2023-12-21T09:35:34.850 app[] ams [info] at endReadableNT (node:internal/streams/readable:1400:12)

2023-12-21T09:35:34.850 app[] ams [info] at processTicksAndRejections (node:internal/process/task_queues:82:21)

2023-12-21T09:35:34.850 app[] ams [info] at cachedError (/app/node_modules/postgres/cjs/src/query.js:170:23)

2023-12-21T09:35:34.850 app[] ams [info] at new Query (/app/node_modules/postgres/cjs/src/query.js:36:24)

2023-12-21T09:35:34.850 app[] ams [info] at sql (/app/node_modules/postgres/cjs/src/index.js:112:11)

2023-12-21T09:35:34.850 app[] ams [info] at getLatestSync (/app/build/index.js:2359:36) {

2023-12-21T09:35:34.850 app[] ams [info] code: 'ECONNRESET',

2023-12-21T09:35:34.850 app[] ams [info] path: undefined,

2023-12-21T09:35:34.850 app[] ams [info] host: undefined,

2023-12-21T09:35:34.850 app[] ams [info] port: undefined,

2023-12-21T09:35:34.850 app[] ams [info] localAddress: undefined

2023-12-21T09:35:34.850 app[] ams [info] }

2023-12-21T09:35:34.852 app[] ams [info] [Error: Unexpected Server Error]

I am unsure what could be the issue or how to diagnose the problem/solution. Any help will be appreciated.

nowfred commented 6 months ago

It doesn't look like you have successfully set any of the environment vars which the library needs to connect to your db

...
port: undefined
...

Make sure those config values are making it to where you init postgres.