Run Hasura GraphQL Engine on Heroku

This guide will help you get Hasura GraphQL engine running as a “git push to deploy” app on Heroku and connecting it to a Heroku Postgres instance. If you want a simple, quick deployment on Heroku, follow this Heroku quickstart guide.

Clone the Hasura GraphQL engine Heroku app

The Hasura app with Heroku buildpack/configuration is available at:

Configure database URL

Edit the command in the Dockerfile to change which database Hasura GraphQL engine connects to. By default, it connects to the primary database in your app which is available at DATABASE_URL.

FROM hasura/graphql-engine:latest

# Change $DATABASE_URL to your Heroku Postgres URL if you're not using
# the primary Postgres instance in your app
CMD graphql-engine \
  --database-url $DATABASE_URL \
  serve \
  --server-port $PORT \

Read about more configuration options here.


Hasura GraphQL engine needs access permissions to your Postgres database as described in Postgres permissions


These are some sample deployment instructions while creating a new app.

Step 1: Create app with –stack=container

Use the Heroku CLI to create a new Heroku app. Let’s call the app graphql-on-postgres.

# Replace graphql-on-postgres with whatever you'd like your app to be called
$ heroku create graphql-on-postgres --stack=container

Creating ⬢ graphql-on-postgres... done, stack is container |



Step 2: Create the Heroku Postgres add-on

Create the Postgres add-on in your Heroku app.

$ heroku addons:create heroku-postgresql:hobby-dev -a graphql-on-postgres

Creating heroku-postgresql:hobby-dev on ⬢ graphql-on-postgres... free
Database has been created and is available
 ! This database is empty. If upgrading, you can transfer
  ! data from another database with pg:copy
  Created postgresql-angular-20334 as DATABASE_URL
  Use heroku addons:docs heroku-postgresql to view documentation

Step 3: git push to deploy

Remember to change HEROKU_GIT_REMOTE to your git remote below. In our case:

$ git init && git add .
$ git commit -m "first commit"
$ git remote add heroku HEROKU_GIT_REMOTE
$ git push heroku master

Visit (replace graphql-on-postgres with your app name) and you should see the Hasura console.