Installing and Running the Emulators


Start course

Picking the right database solution on Google Cloud Platform can be tricky. There are so many options to choose from, and sometimes the differences between them are not very obvious. In this course, you will learn about Firestore, one of Google’s NoSQL databases. We will cover what it can do, how it differs from some other databases, and how to get started using it.

Learning Objectives

  • Understand what Google Cloud Firestore is
  • Learn how to use it to store and retrieve data
  • Know how to create indexes
  • Know how to install the emulators for local development

Intended Audience

  • Database administrators
  • Cloud Architects
  • GCP Developers
  • Anyone preparing for a Google Cloud certification


  • Some experience with databases and writing queries

In this lesson, I am going to show you how to install and run the Datastore and Firestore emulators.  

Whenever developing applications for the cloud, there will be times where you will need to test things locally on a development machine.  Maybe you don’t have internet access, or maybe you simply don’t have your own dedicated Firestore database.  Whatever the case may be, Google has provided a way to emulate Firebase databases running in either Datastore mode or Native mode.  And by using these emulators, you can create a completely isolated development environment.  And this will allow you to more easily track down and fix bugs.

The emulators are provided as optional components in the Google Cloud SDK.  So if you have not installed the SDK, that should be your first step.  Once you have the SDK installed, you can run the following gcloud commands.

It is always a good idea to do a “gcloud update”.  This will make sure you have the latest SDK features and fixes.

After that, we can then view the available emulators.  Here is the command.  You will notice that some components are already installed, but many are not.  If I scroll back up, here you can see the two emulators.  “Cloud-datastore-emulator” will emulate a Firestore database running in Datastore mode.  And “cloud-firestore-emulator” will emulate a Firestore database running in Native move.

So you can choose to install either one or both.  To install a component you just have to use the “gcloud components install” command and then specify the name of the component.  So here is how to install the Datastore mode emulator.  And here is how you install the Native mode emulator.

Now if I list out my components again, I can see that the emulators have been successfully installed.  In addition to installing the emulators, you have two other prerequisites.

First, you need to have a Java Runtime installed and configured.  These emulators require Java to work.  So make sure you have that installed and make sure the Java binary has been added to your system path.  

Second, at the time of this recording, the emulators are still in beta.  That means you will need to have the gcloud SDK Beta commands installed as well.  Review your current components and if the beta commands are not already installed, you might need to run the command: “gcloud components install beta”.

Once you have the prerequisites installed, then you can fire up the emulators.  The command to run Datastore mode looks like this.  And when it is running, you won’t see anything too fancy.  You will get a few logs messages that tell you what host and port number it is running on.  Here we can see it is running on localhost at port 8081.  You will need this information to point your app to the new instance.  You can also verify that the emulator is working by copying and pasting the provided URL.  It is very basic, but this tells me that everything appears to be working.  At this point, the only thing left to do would be to open up your IDE, modify your code to point to the emulator, and then you can build and run everything locally.  Remember initially your local database is going to be empty.

Alright, so this is how you run the Datastore mode emulator.  The Native mode emulator works almost the same way.  Here is the command for running it.  You get a similar output screen.  Here this created an instance running on localhost at port 8040.  So, just like last time, I can verify that everything is working by accessing the status page.

Currently, the emulators are pretty basic.  You can find a little more information at the following URLs:

Remember in order to actually use these, you have to modify your application to point to these emulators.  And that usually is going to require setting a few local environment variables.  Refer to the documentation to get the details for your particular environment.

About the Author
Learning Paths

Daniel began his career as a Software Engineer, focusing mostly on web and mobile development. After twenty years of dealing with insufficient training and fragmented documentation, he decided to use his extensive experience to help the next generation of engineers.

Daniel has spent his most recent years designing and running technical classes for both Amazon and Microsoft. Today at Cloud Academy, he is working on building out an extensive Google Cloud training library.

When he isn’t working or tinkering in his home lab, Daniel enjoys BBQing, target shooting, and watching classic movies.