MySQL + Node.js crash

rayenhmlHOBBY

a year ago

Hello, I have a MySQL database and Node.js running on Railway. My frontend is hosted on Netlify. Actually, when I test, everything is working very well, but after some time the backend crashes, no data is being shown and i can't access the backend with with the Public Networking-Adress. When I redeploy, everything works perfectly again.

Here is the error:
node:events:495

throw er; // Unhandled 'error' event

^

Error: Connection lost: The server closed the connection.

at Socket. (/app/node_modules/mysql2/lib/connection.js:117:31)

at Socket.emit (node:events:517:28)

at TCP. (node:net:350:12)

Emitted 'error' event on Connection instance at:

at Connection.notifyError (/app/nodemodules/mysql2/lib/connection.js:252:12)

at Socket. (/app/node_modules/mysql2/lib/connection.js:123:12)

at Socket.emit (node:events:517:28)

at TCP. (node:net:350:12) {

fatal: true,

code: 'PROTOCOLCONNECTIONLOST'

}

Node.js v18.18.2

[nodemon] app crashed - waiting for file changes before starting…

3 Replies

a year ago

please make sure to close all database connections when not in use.


rayenhmlHOBBY

a year ago

Hello,
thank you for responding. Can you please clarify a little bit more?


As this is unrelated to the Railway product or platform, you may want to try Googling the error you're receiving (e.g. node mysql2 PROTOCOL_CONNECTION_LOST) and reading through the results.