R
Join ServerRailway
✋|help
Postgres connection terminated unexpectedly
Hi, I have a simple express server using typescript with prisma. I have a postgres database hosted on railway.
I cannot figure why the db connection seems to stop brutally and make the app crash
According to the app logs, it happens at random times.
The error is the following:
Is this a known issue ? Am I missing something in the config ?
I cannot figure why the db connection seems to stop brutally and make the app crash
According to the app logs, it happens at random times.
The error is the following:
uncaughtException: Connection terminated unexpectedly
Error: Connection terminated unexpectedly
at Connection.<anonymous> (/app/node_modules/pg/lib/client.js:131:73)
at Object.onceWrapper (node:events:627:28)
at Connection.emit (node:events:513:28)
at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:62:12)
at Socket.emit (node:events:513:28)
at TCP.<anonymous> (node:net:322:12)
Is this a known issue ? Am I missing something in the config ?
f9a74fea-b8e0-4256-bdf0-ff786bd5f870
On the database side the log is:
2023-05-24 05:37:51.137 UTC [24574] LOG: could not receive data from client: Connection reset by peer
2023-05-24 05:37:51.137 UTC [24756] LOG: could not receive data from client: Connection reset by peer
2023-05-24 05:37:51.137 UTC [24757] LOG: could not receive data from client: Connection reset by peer
2023-05-24 05:37:51.138 UTC [24755] LOG: could not receive data from client: Connection reset by peer
are you keeping too many connections open?
I'm following prisma guidelines on this. I don't manually handle connections and let the orm do it. I have only one client shared by my app services. It might use a pool of connections (that's why we see a couple of them on the db logs) instead of just 1.