question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MongoError: E11000 duplicate key error index: sessions.sessions.$sid_1 dup key: { : null }

See original GitHub issue

I get the above mentioned error as soon as more than 1 user tries to login into my system.

I am using MongoStore like this

app.use(express.session({
  key: 'sid',
  secret: 'secret',
  store: new MongoStore({
    db: 'sessions',
    secret: 'mongo store secret!'
  })
});

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
micatecommented, Jul 23, 2013

@dhruvasagar 😃

I just confirmed that collection created by connect-mongo has only two indexes by default: _id_ and expires_1. So the sid_1 index mentioned by the error must be created by other session packages.

0reactions
gabrielstuffcommented, Dec 10, 2013

same here, db.sessions.drop() fixed it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

E11000 duplicate key error index in mongodb mongoose
The error message is saying that there's already a record with null as the email. In other words, you already have a user...
Read more >
E11000 duplicate key error collection - MongoDB
I have an index in collection “persons” which shall avoid inserting duplicate documents with the same person name.
Read more >
MongoError: E11000 duplicate key error collection
However, I encountered an error. MongoError: E11000 duplicate key error collection: companies index: code_1 dup key: { code: null }.
Read more >
MongoDB show duplicate key is null?
The duplicate key message includes the index name and key violation: "errmsg" : "E11000 duplicate key error collection: testdb.setup index: name ...
Read more >
Debug E11000 Errors in Mongoose - Mastering JS
MongoError : E11000 duplicate key error collection: test.customers index: _id_ dup key: { : ObjectId('5cc5ea092dca872442916cf5') }.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found