Answer the question
In order to leave comments, you need to log in
How to fix Connection lost: The server closed the connection error?
After 40 seconds, the connection is disconnected and displays an error
(node:10832) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
events.js:183
throw er; // Unhandled 'error' event
^
Error: Connection lost: The server closed the connection.
at Protocol.end (C:\Users\sskat\Desktop\project\node_modules\mysql\lib\protocol\Protocol.js:113:13)
at Socket.<anonymous> (C:\Users\sskat\Desktop\project\node_modules\mysql\lib\Connection.js:109:28)
at emitNone (events.js:111:20)
at Socket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1055:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
const
mysql = require('mysql'),
{ error } = require('handy-log'),
{ MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE } = process.env
const db = mysql.createConnection({
host: MYSQL_HOST,
user: MYSQL_USER,
password: MYSQL_PASSWORD,
database: MYSQL_DATABASE,
charset: 'utf8mb4'
})
db.connect(err => {
if(err){
error(err.message)
}
})
module.exports = db
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question