title: Error: 14 UNAVAILABLE: No connection established - Cloud Firestore
body: <p>I'm trying to use the admin SDK for firebase on my machine. When I try to get the users collection I get <code>Error: 14 UNAVAILABLE: No connection established</code>. Writing to firestore also does nothing. How can I fix this?</p>
  <p>EDIT
  <a href="https://firebase.google.com/docs/emulator-suite/connect_firestore?hl=en#node.js-admin-sdk" rel="nofollow noreferrer">From the docs</a>:</p>
  <blockquote>
  <p>The Firebase Admin SDKs automatically connect to the Cloud Firestore
  emulator when the FIRESTORE_EMULATOR_HOST environment variable is set</p>
  </blockquote>
  <p>I do have that environment variable set but I'm trying to connect to production. How can I instruct the SDK to do this?</p>
  <pre><code>index.js
  
  const admin = require(&quot;firebase-admin&quot;);
  const serviceAccount = require(&quot;./serviceAccount.json&quot;);
  admin.initializeApp({
    credential: admin.credential.cert(serviceAccount),
    databaseURL: &quot;&quot;
  });
  
  const snapshot =  admin.firestore().collection('users').get().then((snapshot)=&gt;{
    snapshot.forEach((doc) =&gt; {
      console.log(doc.id, '=&gt;', doc.data());
    });
  }).catch(e=&gt;{
    console.error(e);
  });
  </code></pre>
  <p>The full error log:</p>
  <pre><code>PS C:\Users\simeon.ramjit\Documents\projects\controllino-server&gt; node index
  Error: 14 UNAVAILABLE: No connection established
      at Object.callErrorFromStatus (C:\Users\simeon.ramjit\Documents\projects\controllino-server\node_modules\@grpc\grpc-js\build\src\call.js:31:26)
      at Object.onReceiveStatus (C:\Users\simeon.ramjit\Documents\projects\controllino-server\node_modules\@grpc\grpc-js\build\src\client.js:330:49)
      at Object.onReceiveStatus (C:\Users\simeon.ramjit\Documents\projects\controllino-server\node_modules\@grpc\grpc-js\build\src\client-interceptors.js:299:181)
      at C:\Users\simeon.ramjit\Documents\projects\controllino-server\node_modules\@grpc\grpc-js\build\src\call-stream.js:145:78
      at processTicksAndRejections (internal/process/task_queues.js:77:11)
  Caused by: Error
      at CollectionReference._get (C:\Users\simeon.ramjit\Documents\projects\controllino-server\node_modules\@google-cloud\firestore\build\src\reference.js:1450:23)
      at CollectionReference.get (C:\Users\simeon.ramjit\Documents\projects\controllino-server\node_modules\@google-cloud\firestore\build\src\reference.js:1439:21)
      at Object.&lt;anonymous&gt; (C:\Users\simeon.ramjit\Documents\projects\controllino-server\index.js:41:57)
      at Module._compile (internal/modules/cjs/loader.js:1085:14)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
      at Module.load (internal/modules/cjs/loader.js:950:32)
      at Function.Module._load (internal/modules/cjs/loader.js:790:14)
      at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
      at internal/main/run_main_module.js:17:47 {
    code: 14,
    details: 'No connection established',
    metadata: Metadata { internalRepr: Map(0) {}, options: {} }
  }
  </code></pre>