title: SequelizeConnectionRefusedError JSON MySQL
body: <p>Hey there I am trying to have a /create function on my REST server. I work on C9.io</p>
  
  <pre><code>var express = require("express")
  var bodyParser = require("body-parser")
  var cors = require("cors")
  var Sequelize = require("sequelize")
  var util = require("util")
  
  var app  = express()
  app.use(bodyParser.json())
   app.use(cors())
  
  var sequelize = new Sequelize('authordb','root','',{
  dialect : 'mysql',
  port : 3305
  })
  
  var Author = sequelize.define('author',{
  name : Sequelize.STRING,
  email : { 
      type : Sequelize.STRING,
      validate : { 
          isEmail : true
      }
   }
   })
  
   var Message = sequelize.define('message',{
  subject : Sequelize.STRING,
  content : Sequelize.STRING
   })
  
  Author.hasMany(Message, {onDelete : 'cascade'})
  Message.belongsTo(Author)
  
    app.get('/create', function(req,res){
  sequelize.sync()
      .complete(function(err){
          if (err){
              console.log(err)
          }
          else{
              res.status(201).send('created all')
          }
      })
    })
  
   app.post('/authors',function(req,res){
  var author = req.body
  Author.create(author)
      .complete(function(err){
          if (err){
              console.log(err)
          }
          else{
              res.status(201).send('created author')
          }
      })
     })
  
  app.get('/authors/:id',function(req,res){
  Author.find({
      where : {
          id : req.params.id
      },
      attributes : ['id','name','email']
  })
  .complete(function(err,authorDAO){
          if (err){
              console.log(err)
          }
          else{
              // console.log(authorDAO)
              // util.inspect(authorDAO)
              var author = authorDAO.dataValues
              res.status(200).send(author)
          }
    })
     })
  
     app.put('/authors/:id',function(req,res){
     var newValues = req.body
      Author.find({
      where : {
          id : req.params.id
      }
     })
  .success(function(authorDAO) {
      authorDAO.email = newValues.email
      authorDAO.name = newValues.name
      authorDAO.save(['email','name'])
          .success(function(){
              res.status(202).send('modified author')
          })
   })
      })
  
      app.delete('/authors/:id',function(req,res){
     Author.find({
      where : {
          id : req.params.id
      }
   })
  .success(function(authorDAO) {
      authorDAO.destroy()
          .success(function(){
              res.status(202).send('deleted author')
          })
    })
  
      })
  
    app.post('/authors/:id/messages',function(req, res) {
  var message = req.body
  Author.find({
      where : {
          id : req.params.id
      }
  })
  .success(function(authorDAO){
      Message.create(message)
          .success(function(messageDAO){
              authorDAO.addMessage(messageDAO)
                  .success(function(){
                      res.status(201).send('create message')
                  })
          })
       })
     })
  
     app.get('/authors/:id/messages',function(req, res) {
     Author.find({
      where : {
          id : req.params.id
      },
      include : {model : Message, as : 'messages'}
      })
    .success(function(authorDAO) {
      var messages = authorDAO.dataValues.messages
      res.status(200).send(messages)
     })
      })
  
  
    app.listen(8080)
  </code></pre>
  
  <p>The error is : </p>
  
  <pre class="lang-none prettyprint-override"><code>{ [SequelizeConnectionRefusedError: connect ECONNREFUSED]
    name: 'SequelizeConnectionRefusedError',
    message: 'connect ECONNREFUSED',
    parent: 
     { [Error: connect ECONNREFUSED]
       code: 'ECONNREFUSED',
       errno: 'ECONNREFUSED',
       syscall: 'connect',
       fatal: true },
    original: 
     { [Error: connect ECONNREFUSED]
       code: 'ECONNREFUSED',
       errno: 'ECONNREFUSED',
       syscall: 'connect',
       fatal: true } }
  </code></pre>