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.
6 ALREADY_EXISTS: Document already existsError: 6 ALREADY_EXISTSalready-exists FirestoreDocument already exists: projects/p/databases/(default)/documents/FirebaseFirestoreException ALREADY_EXISTS 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
- Use
set(data, { merge: true })for upserts - Use auto IDs (
add()) - Handle ALREADY_EXISTS idempotently
Detailed fix by platform
Node.js
await db.doc("users/alice").set({ name: "Alice" }, { merge: true });
How to diagnose
- Doc — Exists?
- Method — create?
- 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:
Similar errors
- 2714 SQL Server Msg 2714: There is already an object named 'X' in the database
- contention Firestore: 10 ABORTED: Too much contention on these documents. Please try again.
- Firestore: DEADLINE_EXCEEDED / UNAVAILABLE Firestore: 4 DEADLINE_EXCEEDED: Deadline exceeded / 14 UNAVAILABLE: The service is currently unavailable
Most viewed in Google Cloud / Firebase
- Container failed to start Cloud Run: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable
- 409: The resource already exists Compute Engine: ERROR: (gcloud.compute.instances.create) Could not fetch resource: The resource 'projects/p/zones/z/instances/vm-1' already exists
- BigQuery: Unrecognized name BigQuery: Syntax error / Unrecognized name: customer_id at [3:8] (Did you mean customerId?)
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 18 Nov 2026