"ECONNRESET" error in Node.js MySQL application
P粉201448898
P粉201448898 2023-12-26 10:54:38
0
1
518

This error comes from my hosted node mysql application. Works fine on my local machine

node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at TCP.onStreamRead (node:internal/stream_base_commons:217:20)
Emitted 'error' event on Connection instance at:
    at Connection._handleProtocolError (/home/ufkgmlcg/nodevenv/happyface_social/16/lib/node_modules/mysql/lib/Connection.js:423:8)
    at Protocol.emit (node:events:513:28)
    at Protocol._delegateError (/home/ufkgmlcg/nodevenv/happyface_social/16/lib/node_modules/mysql/lib/protocol/Protocol.js:398:10)
    at Protocol.handleNetworkError (/home/ufkgmlcg/nodevenv/happyface_social/16/lib/node_modules/mysql/lib/protocol/Protocol.js:371:10)
    at Connection._handleNetworkError (/home/ufkgmlcg/nodevenv/happyface_social/16/lib/node_modules/mysql/lib/Connection.js:418:18)
    at Socket.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -104,
  code: 'ECONNRESET',
  syscall: 'read',
  fatal: true
}

how to solve this problem?

P粉201448898
P粉201448898

reply all(1)
P粉986028039

It's hard to tell without knowing the details of where the application is hosted, and the code snippet used to connect to mysql.

However, it is very likely that in the code that connects to mysql, you add the path to the localhost where mysql is running, and when you host the application, the path to the mysql database is different.

To resolve this issue, you should read How to connect to mysql on the platform where your application is hosted, and then use environment variables to connect to it.

You will use environment variables to specify the local database path on your computer, and also specify the managed database path in the hosting platform.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!