Deploying subgraph on Ubuntu 18.04

How to deploy a subgraph on VPS

by Ivan#7522 (Discord)

This step-by-step guide describes how to deploy an example subgraph on a VPS with Ubuntu 18.04. After deploying an example, you can play around with it, make changes is mappings, schema, etc. Since some users (including myself) have encountered many difficulties, this guide focuses on all steps, performing which, you will be able to deploy your subgraph flawlessly.

First, you need to get a VPS. Go to Hetzner Cloud (referral link will grant you 20$ bonus). Choose a server (2 CPU will be OK) and operating system (Ubuntu 18.04). When you deploy a server, IP and password will be sent to your e-mail.

In Terminal (standart on mac, or iTerm, or any else), type

ssh root@<IP>

Change <IP> to the IP of your server, press enter and enter your password.

Next, you will need to update and install things like git, yarn and nvm.

sudo apt update
sudo apt upgrade

Installing git

sudo apt install git
git config — global “your-github-username”
git config — global “your-github-email”

Installing nodejs and npm

curl -sL | \sudo -E bash — && \
sudo apt install -y nodejs && sudo npm install -g npm@latest

Installing nvm

wget -qO- | bash
source ~/.profile
nvm install 14.15.1

Installing yarn

curl -sS | sudo apt-key add -
echo “deb stable main” | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install yarn

Now you have completed all possible requirements and we can move on to deploying a subgraph.

Go to and login, using your github account. Go to dashboard an click “Add subgraph”.

Fill in all the fields and click “Create subgraph”.

Now you can see an instruction, which we will walkthrough, access token, which we will need later and current status — undeployed.

In order to deploy subgraph, enter in your terminal:

yarn global add @graphprotocol/graph-cli
graph init --from-example <your-github-username>/<subgraph-name>

Change <your-github-username>/<subgraph-name> to your data. I am using Ivan123-ops/Tbtcgraph here.

Next, find the access token in Graph Dashboard (mentioned before) and type in your terminal:

yarn install
cd <subgraph-name>
yarn codegen
graph deploy --access-token <your-access-token> \
--debug \
--node \
--ipfs \

Change <subgraph-name> to your subgraph name and <your-access-token> to access token found in dashboard. Also don’t forget to change <your-github-username>/<subgraph-name>.

If you see this message, you have successfully deployed your subgraph!

Navigate to Graph Dashboard, where you will see that your subgraph is deployed and synced. Now you can start experimenting on it.

If you have questions, contact me via Discord Ivan#7522

Professional validator, taking part in major testnets and running mainnets.