48 — NamespaceExists

configurationwrite

A collection or index with this name already exists

What is happening?

NamespaceExists is returned when attempting to create a collection, view, or index that already exists. For collections, this happens when explicitly calling createCollection on an existing name. For indexes, it happens when creating an index with a name that already exists but different options.

Common causes

  1. Calling createCollection on a collection that already exists
  2. Creating an index with a name that conflicts with an existing index
  3. Renaming a collection to a name that already exists
  4. Migration script running twice

Diagnostic Steps