DBAtlas · Database operations atlas

67 CannotCreateIndex: Cannot create index

MongoDB

What does it mean?

The index build failed because of a constraint or limit. MongoDB could not build the requested index due to existing data or configuration.

Why does it happen?

Exceeding the maximum number of indexes allowed per collection (64); a key that is too large; or incompatible option combinations (e.g. an unsuitable field type for a TTL index). Note: building a unique index while the existing data contains duplicates raises E11000 DuplicateKey, not this code.

How to fix it

If you hit the index count limit, drop unused indexes (analyze usage with $indexStats). Check key size/type compatibility and the option combination. On large collections, build the index during low load (since 4.2 index builds do not block writes for long anyway; the background option is ignored).

Open in DBAtlas →

More from this engine