title: Running MongoDB in NodeJS Express project on Centos server
body: <p>I have a NodeJS Express project that uses mongoose to access a MongoDB database. When I run the application on my local laptop, it works fine. I want to run it on a Centos VPS hosting.</p>
  
  <p>Without changing anything in the project, I tried <code>npm start</code> in the app directory on the server and I get the following error when I try to use the database:</p>
  
  <pre><code>(AppDir)/node_modules/mongoose/node_modules/mongodb/lib/server.js:242
          process.nextTick(function() { throw err; })
                                              ^
  Error: connect ETIMEDOUT
      at exports._errnoException (util.js:746:11)
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19)
  
  npm ERR! Linux 2.6.32-504.23.4.el6.x86_64
  npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
  npm ERR! node v0.12.6
  npm ERR! npm  v2.11.2
  npm ERR! code ELIFECYCLE
  npm ERR! App@0.0.0 start: `node ./bin/www`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the App@0.0.0 start script 'node ./bin/www'.
  npm ERR! This is most likely a problem with the App package,
  npm ERR! not with npm itself.
  npm ERR! Tell the author that this fails on your system:
  npm ERR!     node ./bin/www
  npm ERR! You can get their info via:
  npm ERR!     npm owner ls App
  npm ERR! There is likely additional logging output above.
  
  npm ERR! Please include the following file with any support request:
  npm ERR!     (AppDir)/npm-debug.log
  </code></pre>
  
  <p>The code in app.js:</p>
  
  <pre><code>var mongoose = require('mongoose');
  var configDB = require('./config/database.js');
  mongoose.connect(configDB.url);
  //some other app functionality
  module.exports = app;
  </code></pre>
  
  <p>The code in config/database.js:</p>
  
  <pre><code>module.exports = {
  
      'url' : 'mongodb://(DB URL)'
  };
  </code></pre>
  
  <p>I use mongoose models to generate, access and edit Collections in the database.
  I can't figure out why it won't work but I think maybe it has to do with the fact that the IP address of the server is different from localhost?</p>
  
  <p>Also, I have researched for a solution and someone suggested to change some things in <code>/etc/mongod.config</code> but for some reason I can't find it...? The file doesn't exist.</p>