Firestore: 6 ALREADY_EXISTS — document already exists (create() on an existing document)

create() or a transaction tried to create a document at a path that is already taken.

Exact message you may see 6 ALREADY_EXISTS: Document already existsError: 6 ALREADY_EXISTSalready-exists FirestoreDocument already exists: projects/p/databases/(default)/documents/FirebaseFirestoreException ALREADY_EXISTS
Seen on: Firebase Node.js Google Cloud

Meaning

Use set() (with merge) or update() when the document may exist, generate IDs with add(), or catch the error and treat it as idempotent success. In batched writes the whole batch fails.

Common causes

  • create() on an existing doc
  • Retry of a create after success
  • Non-unique custom document ID
  • Race between two writers
  • Seed script re-run

⚡ Quick fix

  1. Use set(data, { merge: true }) for upserts
  2. Use auto IDs (add())
  3. Handle ALREADY_EXISTS idempotently

Detailed fix by platform

Node.js

  1. await db.doc("users/alice").set({ name: "Alice" }, { merge: true });

How to diagnose

  1. Doc — Exists?
  2. Method — create?
  3. Retry — Duplicates?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

2714 — SQL Server Msg 2714: There is already an object named 'X' in the database (SQL)2714contention — Firestore: 10 ABORTED: Too much contention on these documents. Please try again. (Google Cloud / Firebase)contentionFirestore: DEADLINE_EXCEEDED / UNAVAILABLE — Firestore: 4 DEADLINE_EXCEEDED: Deadline exceeded / 14 UNAVAILABLE: The service is currently unavailable (Google Cloud / Firebase)Firestore: DEADLINE_E…Firestore: Document exceeds the maximum size of 1,048,576 bytes — Firestore: 3 INVALID_ARGUMENT: The value of property "data" is longer than 1048487 bytes / Document exceeds the maximum size (Google Cloud / Firebase)Firestore: Document e…hotspotting — Firestore write latency/errors: hotspotting from sequential document IDs or indexed fields (Google Cloud / Firebase)hotspottinglimits — Firestore: Invalid Query. 'in' filters support a maximum of 30 elements (query limits) (Google Cloud / Firebase)limitsMissing or insufficient permissions — Firestore: FirebaseError: [code=permission-denied]: Missing or insufficient permissions (Google Cloud / Firebase)Missing or insufficie…offline — Firestore: Failed to get document because the client is offline (unavailable) (Google Cloud / Firebase)offlineALREADY_E…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.