MongoDB E11000 duplicate key error MongoDB E11000 duplicate key error mongodb mongodb

MongoDB E11000 duplicate key error


I think You had model for days collection with date attribute which had unique index date_1.

Now You've removed it but collection still has that index.

so that's why it says:

duplicate key error collection: .days index: date_1 dup key: { : null }

it means You're inserting another record where date attribute is also null.

log in to mongodb from console and try to do this:

db.collectionNameHere.getIndexes();db.collectionNameHere.dropIndex('date_1');db.collectionNameHere.getIndexes();

p.s. feel free to provide any additional data in Your question or in comments, to help me/us to solve Your issue.


drop the collection and run again


I had similar issue and ran into this question and got to read the comment above me. I thought he was trolling at first but I had an epiphany that is difficult to explain. I dropped the collection and store new documents and miraculously the errors are now gone. Maybe it's some mongodb bug, I'm not sure really.