title: connect ETIMEDOUT error while doing POST query in Express js
body: <p>I am writing a simple post call. My code is as follows:</p>
  
  <pre><code>var express    = require('express');        
  var app        = express();                
  var bodyParser = require('body-parser');
  app.use(bodyParser.urlencoded({ extended: true }));
  app.use(bodyParser.json());
  var port = process.env.PORT || 8080;        
  var router = express.Router();             
  var mongoose   = require('mongoose');
  mongoose.connect('mongodb://node:node@novus.modulusmongo.net:27017/Iganiq8o');
  router.use(function(req, res, next) {
  
      console.log('Something is happening.');
      next(); 
  });enter code here
  
  router.get('/', function(req, res) {
      res.json({ message: 'hooray! welcome to our api!' });   
  });
  
  var Bear     = require('./app/models/bears');
  router.route('/bears')    
  .post(function(req, res) {
      var bear = new Bear();     
      bear.name = req.body.name;  
      bear.save(function(err) {
          if (err)
              res.send(err);
  
          res.json({ message: 'Bear created!' });
      });
  
  });
  
  app.use('/api', router);
  app.listen(port);
  console.log('Magic happens on port ' + port);
  </code></pre>
  
  <p>I was previously getting the following error</p>
  
  <p><code>failed to connect to [novus.modulusmongo.net:27017]</code></p>
  
  <p>which I rectified by updating mongoose but now still i am getting another error as:</p>
  
  <pre><code>/node_modules/mongoose/node_modules/mongodb/lib/server.js:242
      process.nextTick(function() { throw err; })
                                    ^
  </code></pre>
  
  <p>Error: connect ETIMEDOUT 54.209.84.209:27017</p>