title: cant connect to Local mongodb server with nodejs
body: <p>when trying to connect to mongo db from the project directory i get this</p>
  
  <p><em>/Users/tadeothompson/Documents/design work/stressful/site/node_modules/connect-mongo/lib/connect-mongo.js:133
            throw err;
                  ^
  MongoError: cannot connect to server
      at Collection.listIndexes (/Users/tadeothompson/Documents/design work/stressful/site/node_modules/mongoose/node_modules/mongodb/lib/collection.js:1712:11)
      at indexInformation (/Users/tadeothompson/Documents/design work/stressful/site/node_modules/mongoose/node_modules/mongodb/lib/db.js:1531:25)
      at Db.indexInformation (/Users/tadeothompson/Documents/design work/stressful/site/node_modules/mongoose/node_modules/mongodb/lib/db.js:1498:44)
      at ensureIndex (/Users/tadeothompson/Documents/design work/stressful/site/node_modules/mongoose/node_modules/mongodb/lib/db.js:1003:8)
      at Db.ensureIndex (/Users/tadeothompson/Documents/design work/stressful/site/node_modules/mongoose/node_modules/mongodb/lib/db.js:982:44)
      at ensureIndex (/Users/tadeothompson/Documents/design work/stressful/site/node_modules/mongoose/node_modules/mongodb/lib/collection.js:1772:13)
      at Collection.ensureIndex (/Users/tadeothompson/Documents/design work/stressful/site/node_modules/mongoose/node_modules/mongodb/lib/collection.js:1760:44)
      at connectionReady (/Users/tadeothompson/Documents/design work/stressful/site/node_modules/connect-mongo/lib/connect-mongo.js:141:27)
      at Db.collection (/Users/tadeothompson/Documents/design work/stressful/site/node_modules/mongoose/node_modules/mongodb/lib/db.js:425:20)
      at initWithNativeDb (/Users/tadeothompson/Documents/design work/stressful/site/node_modules/connect-mongo/lib/connect-mongo.js:207:20)
      at process._tickCallback (node.js:355:11)
      at Function.Module.runMain (module.js:503:11)
      at startup (node.js:129:16)
      at node.js:814:3</em></p>
  
  <p>managed to connect using a simple app (code below)</p>
  
  <pre><code>*
  
  var MongoClient = require('mongodb').MongoClient;
      // Connect to the db
      MongoClient.connect("mongodb://localhost:27017/exampleDb", function(err, db) {
        if(!err) {
          console.log("We are connected");
        }
      });
  </code></pre>
  
  <p>*</p>
  
  <pre><code>the main node file of the app in question code is below:
  
  
  var express = require('express');
  var bodyParser = require('body-parser');
  var cookieParser = require('cookie-parser');
  var expressSession = require('express-session');
  var mongoStore = require('connect-mongo')({session: expressSession});
  var mongoose = require('mongoose');
  require('./models/users_model.js');
  var conn = mongoose.connect('mongodb://localhost:27017/stressfullproject');
  var app = express();
  app.engine('html', require('ejs')._express); 
  app.set('views', './site' + '/views');        
  app.set('view engine', 'html');
  app.use(bodyParser());
  app.use(cookieParser());
  app.use(expressSession({
      secret: 'stress',
      cookie: {maxAge: 60*60*1000},
      store: new mongoStore({
          db: mongoose.connection.db,
          collection: 'sessions'
      })
  }));
  require('./routes/routes')(app);
  app.listen(80);
  </code></pre>
  
  <p>*</p>
  
  <p>my defined schema</p>
  
  <pre><code> *var mongoose = require('mongoose'),
      Schema = mongoose.Schema;
  var UserSchema = new Schema({
      username: { type: String, unique: true },
      email: String,
      hashed_password: String
  })
  mongoose.model('User', UserSchema)*
  </code></pre>
  
  <p>because i can connect with the other app, im thinking its an issue with one of my modules? ive searched all over. </p>
  
  <p>thanks in advance</p>