R
Railway9mo ago
iroh

Error: lost connection with pg db (node, express)

Hello folks, I’ve deployed a Node.js app with Express on Railway. Everything works fine, but every day around 1 AM, my app crashes because the connection to my database (also deployed on Railway) is lost. Do you have any tips to solve this strange issue? Here is my log from Railway: node:events:495 throw er; // Unhandled 'error' event ^ Error: Connection terminated unexpectedly at Connection.<anonymous> (/app/node_modules/pg/lib/client.js:132:73) at Object.onceWrapper (node:events:631:28) at Connection.emit (node:events:517:28) at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:63:12) at Socket.emit (node:events:517:28) at TCP.<anonymous> (node:net:350:12) Emitted 'error' event on Client instance at: at Client._handleErrorEvent (/app/node_modules/pg/lib/client.js:341:10) at Connection.<anonymous> (/app/node_modules/pg/lib/client.js:150:16) at Object.onceWrapper (node:events:631:28) [... lines matching original stack trace ...] at TCP.<anonymous> (node:net:350:12) Node.js v18.18.2 npm WARN config production Use --omit=dev instead.
5 Replies
Percy
Percy9mo ago
Project ID: N/A
iroh
irohOP9mo ago
N/A * MORE INFO: I already set a pool settings whith an idle timeout value.
Brody
Brody9mo ago
you would need to make sure you are closing and flushing unused connections, this can often be done by setting the pool minimum to zero
iroh
irohOP9mo ago
@Brody thanks, for the reply. I’m using the default sequelize settings + idle timeout value of 50000. According to the docs by default it’s already zero (pool minimum) and max it’s 5
Brody
Brody9mo ago
it seems somehow closed connections are still being kept in the pool
Want results from more Discord servers?
Add your server