AWS RDS Postgres query fails

Hi,
I have a Remix app with AWS RDS Postgres as my managed DB with SSL enabled.
I successfully deployed a blank application, but my own application is encountering errors.
The page that is initially supposed to be displayed, uses defer to return data from the loader.
My application works locally but unfortunately when deploying I get these errors:

2023-12-20T18:16:22.995 app[...] ams [info] Error: Client network socket disconnected before secure TLS connection was established

2023-12-20T18:16:22.995 app[[...] ams [info] at connResetException (node:internal/errors:720:14)

2023-12-20T18:16:22.995 app[[...] ams [info] at TLSSocket.onConnectEnd (node:_tls_wrap:1714:19)

2023-12-20T18:16:22.995 app[[...] ams [info] at TLSSocket.emit (node:events:529:35)

2023-12-20T18:16:22.995 app[[...] ams [info] at endReadableNT (node:internal/streams/readable:1400:12)

2023-12-20T18:16:22.995 app[[...] ams [info] at processTicksAndRejections (node:internal/process/task_queues:82:21)

2023-12-20T18:16:22.995 app[[...] ams [info] at cachedError (/app/node_modules/postgres/cjs/src/query.js:170:23)

2023-12-20T18:16:22.995 app[[...] ams [info] at new Query (/app/node_modules/postgres/cjs/src/query.js:36:24)

2023-12-20T18:16:22.995 app[[...] ams [info] at sql (/app/node_modules/postgres/cjs/src/index.js:112:11)

2023-12-20T18:16:22.995 app[[...] ams [info] at getLatestSync (/app/build/index.js:2359:36) {

I am unsure what could be the issue or how to diagnose the problem/solution. Any help will be appreciated.
P.S. I tried to return a json instead of defer and I don’t get these errors, just error 500 instead with no logs in both the client console or the server’s console.

Edit: I should add that I used ssh to connect to the running machines and I successfuly connected to my db.
This is my code that I use to initialize the db object in my server:

const sql = postgres(process.env.DATABASE_URL, {
    ssl: true,
    idle_timeout: 20,
    max_lifetime: 60 * 30,
    transform: {
        undefined:null
    }
});

export default sql;

And this is the format of the env variable:
DATABASE_URL="postgres://user:pass@dburl:port/db?sslmode=require&search_path=app"

Forgive the obvious question - are you sure you’re able to connect to the database from outside the VPC? E.g. can you connect to your RDS instance from your local environment?

Yes, I’ve been developing on the database for the past few weeks now.

Update: I am unsure what went wrong with the deployment, but I did the same on Heroku and it’s working there so I will be moving there in this case.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.