How to deploy Hasura GraphQL engine to Heroku
Tags: hasura, heroku
Published: 2021-09-22 13:58:45

---
title: How to deploy Hasura GraphQL engine to Heroku
published: true
description: You'll learn how to deploy Hasura GraphQL engine to Heroku
tags: hasura, heroku
cover_image: https://i.imgur.com/RcTPDWZ.png
series: All about JAMstack
---
## __Introduction__

Hasura gives you a GraphQL Application Programming Interface (API) that you can point to your data sources and Heroku provides you a platform that you can host such data sources.

In this article, you'll learn how to deploy a Hasura GraphQL engine on Heroku, and how to secure it from unauthorized access.

## __First steps__

[Sign up for an account on Heroku](https://signup.heroku.com/), if you already have an account, you should log in.

![Heroku login page on Firefox 92](https://i.imgur.com/RcTPDWZ.png)

Once you are logged in, open another tab and navigate to [Deploy Hasura with a new Postgres DB on Hasura docs](https://hasura.io/docs/latest/graphql/core/deployment/deployment-guides/heroku.html#deploying-hasura-with-a-new-postgres-db), scroll down until you locate a button which reads "Deploy on Heroku".

![Deploy Hasura to Heroku on Hasura dics](https://i.imgur.com/QtcsWHu.png)

Click on it, this should redirect you to Heroku with an Hasura engine ready to be deployed and it'll point to a Postgres database hosted on Heroku

![Hasura Engine ready for deployment on Heroku](https://i.imgur.com/ooxt3AA.png)

Fill in your desired details, and click on `Deploy app`.

It'll take some minutes, and you'll notice the build log.

![Build log of Hasura on Heroku](https://i.imgur.com/scZZUzY.png)

if all goes well, you should have a screen similar to the image below.

![Successful deployment if Hasura](https://i.imgur.com/a6tj6Ho.png)

Click on View, this will redirect you to a web page console on Hasura, where you can interact with your database hosted on Heroku.

![Hasura web page console on Firefox 92](https://i.imgur.com/E3hGPHq.png)

Now, you can perform your desired operation on the database and you also get a nice GraphiQL interface that allows you to interact with your data.

But, you are not done.

Copy the URL of your app and open it in another browser, you'll have access to the Hasura engine without authentication.

![Hasura web console in Google Chrome 93](https://i.imgur.com/xR1j8kA.png)<figcaption>The Hasura GraphQL engine on Chrome</figcaption>

Leave this browser tab open, and let's fix this.

## __How To Secure Hasura GraphQL Endpoint__

Navigate back to the browser that you used to deploy Hasura (in my case it's Firefox), and click on Manage App.

![Hasura successful deployment options on Heroku with the option "Manage App" highlightef](https://i.imgur.com/MTVIFES.png)

Locate the Settings tab, scroll down and locate `Config Vars` and click on `Reveal Config Vars`

![Reveal Config Vars on Heroku](https://i.imgur.com/Jcslb3E.png)

Now, you'll need to add a new `KEY` and `VALUE`. This key should be named `HASURA_GRAPHQL_ADMIN_SECRET` and Its value will be the password that you'll use to log in to your Hasura instance.

![New admin secret added to heroku](https://i.imgur.com/tmjx0a5.png)

Click on Add.

Now, navigate to the other browser where you initially logged in without authentication, try navigating to another page, or refresh the page.

You'll be greeted with a login screen.

![Hasura Login Screen on Chrome 93](https://i.imgur.com/ffQTShH.png)

Enter the value of the `HASURA_GRAPHQL_ADMIN_SECRET` that you saved on Heroku, if it's correct you should have access.

You'll also notice there is a new key under `Request Headers` called `x-hasura-admin-secret`.

![An authenticated user logged in to a Hasura Web console](https://i.imgur.com/ksS8Vgz.png)

## __Conclusion__

This article explained how to deploy an Hasura instance on Heroku and how to secure it using an admin secret that will prevent unauthorized access.