MongoDB E11000 duplicate key error

drop the collection and run again


Although the answer from @num8er is totally correct, but an easier approach to do that is: Go to your MongoDB collections => you will have the indexes tab, when you go to that tab you will see the different index rows that you have created, and then just push the Drop Index button of the rows you don't want or just drop all of them and start again.


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.