Running Neo4j on Google Cloud

David Allen
Apr 15, 2018 · 4 min read

Recently, Neo4j made available VM-based images for running both community and enterprise in Google Cloud. Before this, plenty of people were already doing it, but generally had to roll their own and figure out how to do the cloud-specific configuration bits themselves. With these new GCP images though, the process just got a lot easier.

This article shows just how easy this has become. We’ll set up a neo4j instance on GCP, configure firewall rules to allow us to access it, and connect Neo4j Desktop to show how to use a cloud instance with other tooling. In this article we will be working with single-node neo4j deploys. If you’re looking for multi-node clusters, neo4j has separate instructions for those.

Launching a VM

All we need is two commands. The fact that it’s so easy to automate this means you can include it in scripts or CI/CD pipelines, as needed.

gcloud compute firewall-rules create allow-neo4j-bolt-https \
--allow tcp:7473,tcp:7687 \
--source-ranges 0.0.0.0/0 \
--target-tags neo4j
gcloud compute instances create my-neo4j \
--scopes https://www.googleapis.com/auth/cloud-platform \
--image-project launcher-public --tags neo4j \
--image=neo4j-community-1-3-3-5

The first command configures firewall rules according to the instructions on neo4j’s site. Port 7473 is for HTTPS access to Neo4j Browser (the web-based shell we use to interact with the database). Port 7687 is for the binary Bolt protocol, to send queries to the database. The “source ranges” allows all traffic from the entire internet, and the “target tags” simply indicates that this rule applies to any VM in your google project that is tagged “neo4j”.

The second command creates a neo4j instance from the image named “neo4j-community-1–3–3–5” in the “launcher-public” project, and tags that image with “neo4j”. Because we’re tagging the image neo4j, the firewall rules will apply, and we’ll be able to access it via those two ports. This will use an n1-standard VM, if you’d like more or less hardware you can consult the gcloud documentation.

If all goes well, you’ll see output like this:

Created [https://www.googleapis.com/compute/v1/projects/my-project/zones/us-east1-b/instances/my-neo4j].NAME      ZONE        MACHINE_TYPE   PREEMPTIBLE  INTERNAL_IP  EXTERNAL_IP     STATUSmy-neo4j  us-east1-b  n1-standard-1               10.142.0.3   35.196.123.210  RUNNING

After waiting a minute or two to allow the system service on the VM to come up, we can go to https://YOUR_VM_IP:7473 and log into neo4j using the default username and password neo4j/neo4j. Make sure to change the password immediately. Don’t worry if your browser gives you an SSL warning, this is expected since we haven’t configured an SSL certificate.

If you prefer, you can use all of the existing tools like cypher-shell and others to work with this database directly by its public IP and 7867 bolt port.

Our fresh new (blank) database

Community, or Enterprise? Either works.

In the commands above, we launched neo4j-community-1–3–3–5. If we wanted enterprise, we could simply instead launch neo4j-enterprise-1–3–3-5. Both are work fine. If you have an evaluation or commercial license, or you’re in the Neo4j startup program, you can use enterprise.

Connecting your GCP Instance with Neo4j Desktop

After starting Neo4j Desktop, click on “New Project” in the left pane. Edit the project name like below, and click on “Connect to Remote Graph”.

Creating a new remote connection

You can then enter in the details of how to connect to your instance:

Following this screen, you’ll be asked for your username and password. Because we changed it from the default in the last step, make sure to use the one you changed it to here.

When finished with the configuration dialog, hit the “activate” button.

Once activated, this database in neo4j can be treated as if it was local.

Deleting your GCP Instance

Using the gcloud utility, it’s just one last command:

$ gcloud compute instances delete my-neo4jThe following instances will be deleted. Any attached disks configuredto be auto-deleted will be deleted unless they are attached to anyother instances or the `--keep-disks` flag is given and specifies themfor keeping. Deleting a disk is irreversible and any data on the diskwill be lost.- [my-neo4j] in [us-east1-b]Do you want to continue (Y/n)?  y

Neo4j Developer Blog

Developer Content around Graph Databases, Neo4j, Cypher, Data Science, Graph Analytics, GraphQL and more.

David Allen

Written by

Neo4j Developer Blog

Developer Content around Graph Databases, Neo4j, Cypher, Data Science, Graph Analytics, GraphQL and more.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade