Firestore emulator: Error: 14 UNAVAILABLE
See original GitHub issueFirebase CLI 7.10.0 Firestore emulator 1.10.2
index.js:
const functions = require ('firebase-functions');
const admin = require ('firebase-admin');
admin.initializeApp();
const firestore = admin.firestore();
exports.helloWorld = functions.https.onRequest (async (req, res) => {
const docRef = firestore.collection ('col').doc ('doc');
await docRef.set ({foo: 'bar'});
const docSnap = await docRef.get();
const wroteCorrectly = docSnap.get ('foo') == 'bar';
res.send (wroteCorrectly ? 'Worked' : 'Did not work');
});
Expected: ‘Worked’. Instead: Error: 14 UNAVAILABLE: No connection established (etc.)
- FIRESTORE_EMULATOR_PORT is set (8080).
- GOOGLE_APPLICATION_CREDENTIALS are set.
- This runs fine on the remote Firestore. Only a problem when using local emulator.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Error: 14 UNAVAILABLE: No connection established - Cloud ...
I'm trying to use the admin SDK for firebase on my machine. When I try to get the users collection I get Error:...
Read more >Install, configure and integrate Local Emulator Suite - Firebase
The Firebase Local Emulator Suite can be installed and configured for different prototype and test environments, anything from one-off prototyping sessions ...
Read more >Port 8080 is not open on localhost, could not start Firestore ...
This error is because of the failed quitting from firebase emulator. You already have the process of previous firebase emulator.
Read more >Incidents - Firebase Status Dashboard
For incidents related to Cloud Functions, Cloud Firestore and Cloud ... Firebase Messaging is experiencing periods of errors on app registrations and ...
Read more >Errors and Error Handling | Cloud Datastore Documentation
Error Codes. When a Firestore in Datastore mode request is successful, the API will return an HTTP 200 OK status code along with...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@bwhrsc thanks for your feedback, it shows that some things are not documented as clearly as they could be.
FIRESTORE_EMULATOR_HOST
is an environment variable you can set to tell Firebase SDKs to talk to the emulator rather than to production. It does not control where the emulator runs. To set that, you change a value infirebase.json
:So when you want to run tests against the emulator you can use one of two methods.
Method 1: Manual In one terminal, run the emulators:
In another terminal, run your tests and set the env var:
Method 2: Automatic In your terminal, run:
The above command will do the following things, in order:
FIRESTORE_EMULATOR_HOST
, etc) setupnpm run test
or anything else) in that subprocessSo I believe that should fix your issue. Let me know if something is still not working!
Tip: Try removing the protocol from your hostname
i.e.:
becomes