Connection being refused

0

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

    
asked by anonymous 03.08.2018 / 13:14

1 answer

1

As described in your question (by error returned) your server is trying to connect to the database in localhost , check that the object with the connection settings has the correct information in the% / p>     

03.08.2018 / 14:55