Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Firestore API Returns NOT_FOUND (gRPC Error 5) for Document Visible in Console

Hi everyone,

I'm facing a puzzling issue with Firestore. My Node.js backend application consistently receives a 5 NOT_FOUND error when trying to fetch a specific Firestore document, even though I can verify through the Firebase/GCP Console that the document definitely exists and is accessible there.

Environment:

  • Backend: Node.js
  • Firestore Client Library: @Google-cloud/firestore (inferred from error source)
  • Project ID: wimade-it-455416
  • Database Instance: (default)
  • Document Path: custConfigChat/test

Problem Description:

  1. My Node.js backend code uses the @Google-cloud/firestore library to fetch the document at path custConfigChat/test from the (default) database.
  2. This operation fails, and the following error is logged, indicating a NOT_FOUND status code from the underlying gRPC call:
    Error: 5 NOT_FOUND:
        at callErrorFromStatus (/app/node_modules/@grpc/grpc-js/build/src/call.js:32:19)
  3. I have logged into the Firebase/GCP Console for project wimade-it-455416. From the Console's Firestore viewer, selecting the (default) database, I can navigate to the custConfigChat collection and see the document with the exact ID test. I can open it and view its contents.

Checks Performed:

  • I have carefully verified the Project ID (wimade-it-455416), database instance ((default)), collection name (custConfigChat), and document ID (test) used in my Node.js code, ensuring they exactly match what's shown in the console (including case sensitivity).
  • My application authenticates using standard methods (likely Application Default Credentials or a Service Account key loaded via GOOGLE_APPLICATION_CREDENTIALS).
  • I have also verified the IAM roles assigned to the service account (or principal) executing this code. It appears to have the necessary Firestore permissions (e.g., the 'Cloud Datastore User' role).
  • I have also confirmed that the required APIs (specifically the Cloud Firestore API) are enabled in the Google Cloud project (wimade-it-455416).
  • I confirmed the document path is correct (it's a top-level collection custConfigChat containing the document test within the default database).

Question:

Given that the document /custConfigChat/test definitely exists in the (default) database, is accessible via the Console, the executing principal appears to have the correct IAM permissions, and the Cloud Firestore API is enabled, what could cause the Firestore API (via the Node.js client library) to return a 5 NOT_FOUND error?

I understand NOT_FOUND usually means the document doesn't exist at that path, but the Console access and these configuration checks seem to contradict this. Are there other potential reasons for this specific error code in this scenario, such as:

  • Subtle permission issues specific to the API call / authentication context that aren't covered by standard IAM roles or are perhaps overridden by complex Security Rules (although NOT_FOUND seems less likely for rule denials)?
  • Issues related to Firestore database regions or potential (though unlikely for reads) data consistency delays?
  • Any known quirks or specific configuration requirements for the @Google-cloud/firestore library when running in my environment that might lead to this, especially concerning the default database?

I'm looking for possible explanations beyond simple "document doesn't exist", typos in the path/ID, or obvious IAM/API enablement issues, as I believe I've ruled those out. Any insights into why the API interaction would differ from the Console view would be very helpful.

Thanks in advance!

Solved Solved
0 2 666
1 ACCEPTED SOLUTION

@mcbsalceda 
Thanks for sharing those suggestions — I really appreciate you taking the time to help out!
I had already seen that GitHub discussion and tried those steps, but unfortunately none of them solved my issue.

In my case, the root cause was that I initially went directly to the Firebase Console, where I was prompted to create a new project. Without realizing it, this placed Firebase in the wrong GCP project.

What eventually solved it was this:

  • I went to Firebase via the GCP Console (instead of firebase.google.com directly).
  • This showed a different interface, tied to my actual intended GCP project.
  • There, I re-initialized Firebase and recreated the database under the correct GCP project.

After setting it up correctly under the intended project, everything worked as expected.
Hopefully this helps someone else facing a similar situation!

Let me know if you'd like more details on the setup path I used via GCP.
Again — thanks a lot for your input and the effort, it’s much appreciated! 🙏

View solution in original post

2 REPLIES 2

Hi @dan1701,

I came across a similar issue in GitHub that could help resolve your problem. Here are a few suggestions from the discussion that you might want to try.:

  • @lahirumaramba: Did you enable Firestore from the Firebase console? I have seen this error before when Firestore is not properly set up from the console.



  • @sr5434: I was able to get the code working when I used the Firebase NPM package on the backend and created a web app in the firebase console.
  • @ugursirmen: @dconeybe Hello, I experienced this issue nowadays and I realized that I deleted '(default)' named database. If you have not this default, you cannot access another one, I know this is stupid but when I re-created a database with '(default)' name and use it, the error resolved 🙂 I hope this was helpful. 

  • @tobyL05: I managed to solve this issue by adding my database id to getFirestore() like so getFirestore(<database_id>). I didn't realize/forgot that I set my own custom database id in the Firebase Console when I created my database nor did I realize that the database id was there on the console the whole time.

Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.

@mcbsalceda 
Thanks for sharing those suggestions — I really appreciate you taking the time to help out!
I had already seen that GitHub discussion and tried those steps, but unfortunately none of them solved my issue.

In my case, the root cause was that I initially went directly to the Firebase Console, where I was prompted to create a new project. Without realizing it, this placed Firebase in the wrong GCP project.

What eventually solved it was this:

  • I went to Firebase via the GCP Console (instead of firebase.google.com directly).
  • This showed a different interface, tied to my actual intended GCP project.
  • There, I re-initialized Firebase and recreated the database under the correct GCP project.

After setting it up correctly under the intended project, everything worked as expected.
Hopefully this helps someone else facing a similar situation!

Let me know if you'd like more details on the setup path I used via GCP.
Again — thanks a lot for your input and the effort, it’s much appreciated! 🙏