2

I have a mongoose and connect-mongo module instance in ym app. I am using the connect-mongo module to have a session store persisted in a mongodb database (mongohq) instead of a memory store.

Everytime I try to access my app when the server is launched (facebook auth with everyauth) I get the following:

500 MongoError: Error: unauthorized db:express-sessions lock type:-1 client:199.192.242.4

My user name, password are good.

var conf = {
  db: {
    db: 'express-sessions',
    host: 'staff.mongohq.com',
    port: 10072,  // optional, default: 27017
    username: 'admin', // optional
    password: 'admin', // optional
    collection: 'facebookSessions' // optional, default: sessions
  },
  secret: '076ee61d63aa10a125ea872411e433b9'
};

app.use(express.session({
    secret: conf.secret,
    maxAge: new Date(Date.now() + 3600000),
    store: new MongoStore(conf.db)
  }));

Edit, this seems to be an issue with my mongohq. I modified the collection for an older one and it works.

guiomie
  • 4,988
  • 6
  • 37
  • 67

2 Answers2

3

I was facing a similar error using Heroku and Mongolab.

I resolved it by manually create a new database user with the mongolab web admin.

Adrien Schuler
  • 2,395
  • 1
  • 21
  • 32
0

It sounds like the db was started with --auth but the user has not been granted access to the db.

http://www.mongodb.org/display/DOCS/Security+and+Authentication

aaronheckmann
  • 10,625
  • 2
  • 40
  • 30
  • Hi, it says "You must either have added a user to the admin db before starting the server with authentication, or add the first user from the localhost interface (you cannot add the first user from a connection that is not local with respect to mongod)." ... how can I do this with mongohq ? – guiomie May 10 '12 at 02:38