0

I'm having the following error when I try to start my node application:

Unhandled rejection SequelizeConnectionError: Connection lost: The server closed the connection.
    at Handshake._callback (/Users/move/Vagrant/apps/appcampinas/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:95:20)
    at Handshake.Sequence.end (/Users/move/Vagrant/apps/appcampinas/node_modules/mysql/lib/protocol/sequences/Sequence.js:86:24)
    at /Users/move/Vagrant/apps/appcampinas/node_modules/mysql/lib/protocol/Protocol.js:399:18
    at Array.forEach (native)
    at /Users/move/Vagrant/apps/appcampinas/node_modules/mysql/lib/protocol/Protocol.js:398:13
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Has anyone seen this error before?

Thanks!

1 Answers1

0

Sequelize does not support automatic reconnects, so if your application runs idle the connection could get dropped.

The preferred way to deal with this is to use a connection pool.

{
  "development": {
    "username": "root",
    "password": "root",
    "database": "app_development",
    "host": "127.0.0.1",
    "dialect": "mysql",
    "pool": {
      "maxConnections": 100,
      "maxIdleTime": 1000
    },
    "define": {
      "underscored": true,
      "freezeTableName": true,
      "paranoid": true,
      "charset": "utf8"
    }
  }
}
Reza Karami
  • 505
  • 1
  • 5
  • 15
  • Good Morning, I included this code on my connection but the error is still appearing :/ Any other idea of what can I do? Thanks! – Alexandre Mar 10 '17 at 14:01