title: Cannot Connect to MongoDB with Bitnami MEAN STACK using Mongoose
body: <p>I purchased the MEAN tech stack from AWS (Bitnami to be specific) and have been eagerly trying to learn how to deploy my first node app. However, I have been hitting so many walls with actually getting my mongo connection to work.
  I have read documentation and tried various recipes to fix the issue below</p>
  
  <p>The root admin password has been reset. Here is the proof that I am using the correct pair of username and password</p>
  
  <pre><code>&gt; bitnami@ip-172-31-43-127:~/edupal$ sudo mongo admin --username root --password
  pwdremoved
  MongoDB shell version: 3.0.3
  connecting to: /opt/bitnami/mongodb/tmp/mongodb-27017.sock:27017/admin
  Server has startup warnings:
  2015-06-09T20:11:33.967+0000 I CONTROL  [initandlisten]
  2015-06-09T20:11:33.967+0000 I CONTROL  [initandlisten] ** NOTE: This is a 32 bi
  t MongoDB binary.
  2015-06-09T20:11:33.967+0000 I CONTROL  [initandlisten] **       32 bit builds a
  re limited to less than 2GB of data (or less with --journal).
  2015-06-09T20:11:33.967+0000 I CONTROL  [initandlisten] **       See http://doch
  ub.mongodb.org/core/32bit
  2015-06-09T20:11:33.967+0000 I CONTROL  [initandlisten]
  &gt; show dbs
  admin  0.078GB
  local  0.078GB
  users  0.078GB
  &gt; use users
  switched to db users
  &gt; db.myCollection.find()
  { "_id" : ObjectId("5578c11040a096b7fef84aad"), "name" : "Bill", "score" : "9" }
  </code></pre>
  
  <p>So far, I believe I am in good standing in terms of credentials. Here is how I am connecting to my database</p>
  
  <pre><code>// Connect to MongoDB
  mongoose.createConnection('mongodb://root:pwdremoved@/opt/bitnami/mongodb/tmp/
  mongodb-27017.sock/admin');
  mongoose.connection.once('open', function() {
  
    // Load the models.
    app.models = require('./models/index');
  
    // Load the routes.
    var routes = require('./routes');
    _.each(routes, function(controller, route) {
      app.use(route, controller(app, route));
    });
  
    console.log('Listening on port 3000...');
    app.listen(8080);
  });
  </code></pre>
  
  <p>I followed the tutorial <a href="https://wiki.bitnami.com/Infrastructure_Stacks/BitNami_MEAN_Stack_%28MongoDB,_Express,_Angular,_Node.js%29?highlight=MEAN" rel="nofollow">here</a></p>
  
  <p>and I keep getting this error</p>
  
  <pre><code>bitnami@ip-172-31-43-127:~/edupal$ npm start
  
  &gt; app@0.0.0 start /home/bitnami/edupal
  &gt; node ./bin/www
  
  events.js:85
        throw er; // Unhandled 'error' event
              ^
  Error: failed to connect to [/opt/bitnami/mongodb/tmp/mongodb-27017.sock:27017]
      at null.&lt;anonymous&gt; (/home/bitnami/edupal/node_modules/mongoose/node_modules
  /mongodb/lib/mongodb/connection/server.js:555:74)
      at emit (events.js:118:17)
      at null.&lt;anonymous&gt; (/home/bitnami/edupal/node_modules/mongoose/node_modules
  /mongodb/lib/mongodb/connection/connection_pool.js:150:15)
      at emit (events.js:110:17)
      at Socket.&lt;anonymous&gt; (/home/bitnami/edupal/node_modules/mongoose/node_modul
  es/mongodb/lib/mongodb/connection/connection.js:534:10)
      at Socket.emit (events.js:107:17)
      at net.js:459:14
      at process._tickCallback (node.js:355:11)
  
  npm ERR! Linux 3.13.0-53-generic
  npm ERR! argv "/opt/bitnami/nodejs/bin/.node.bin" "/opt/bitnami/nodejs/bin/npm"
  "start"
  npm ERR! node v0.12.4
  npm ERR! npm  v2.11.1
  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!     /home/bitnami/edupal/npm-debug.log
  </code></pre>
  
  <p>I am not sure what I am doing wrong and have tried many variations of connecting to MongoDB....I've been stuck for two days now.</p>