2

I'm try to use Heroku with Mongo for an Express.js project. Struggling with the connecting to mongohq. Logs output :

connstring is: mongodb://heroku:XXXXXXXXXXXXXXXXXXXXXXXX@staff.mongohq.com:10073/app676842 host is: staff.mongohq.com

app.configure(function() {
  app.set('connstring', process.env.MONGOHQ_URL 
          || ('mongodb://' + app.set('m_host') + '/' +    app.set('m_database')));
  console.log('connstring is: ' + app.set('connstring'));
  var uri = parseUri(app.set('connstring'));
  console.log('host is: ' + uri.host);
  app.use(express.bodyParser());
  app.use(express.cookieParser());

  // use connect-mongo as session middleware
  app.use(express.session({
    secret: 'topsecret',
    store: new store({ db: app.set('m_database'), host: uri.host })
  }));
  app.use(express.methodOverride());
  app.use(app.router);

  // use express logger
  app.use(express.logger({ format: '\x1b[1m:method\x1b[0m \x1b[33m:url\x1b[0m :response-time ms' }));
  app.use(express.static(__dirname + '/public'));
});
kelloti
  • 8,705
  • 5
  • 46
  • 82
jbg
  • 993
  • 1
  • 11
  • 19

1 Answers1

6

Did you set a password?

Try changing your connect string to:

mongodb://heroku:YourPassword@staff.mongohq.com:10073/app676842

assuming your username is set to "heroku"

Cris-O
  • 4,989
  • 3
  • 17
  • 11
  • yeah, that connection string is coming from Heroku: process.env.MONGOHQ_URL. . .so I think that IS my password. :-/ – jbg Aug 06 '11 at 12:22
  • 7
    On heroku, go to your site -> resources -> mongoHQ Then -> Database users and click on edit (the pencil icon) you should see: Edit Database user: username password create a password there, and use that. That's what I did, using mongoose, and it worked fine – Cris-O Aug 06 '11 at 22:22