Following this tutorial of Vedovelli on node with restify and mysql, implemented on the server with pm2.
Only after a few days the connection started to be refused
You're showing this message:
errno: 'ECONNREFUSED',
code: 'ECNNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 3306,
fatal: true
PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR
Theerrorisgivingthisparthere,inthefile auth.js :
authenticate: (email, password) => {
return new Promise((resolve, reject) => {
const {connection, errorHandler} = deps
const queryString = 'SELECT id, email FROM users WHERE email = ? AND password = ?'
const queryData = [email, sha1(password)]
connection.query(queryString, queryData, (error, results) => {
if (error || !results.length) {
errorHandler(error, 'Falha ao localizar o usuário', reject)
return false
}
const {email, id} = results[0]
const token = jwt.sign({email, id}, process.env.JWT_SECRET, { expiresIn: 60 * 60 * 24 })
resolve({token})
})
})
}
My whole project is here in case you want to look at it
The strange thing in localhost works