Hasura GraphQL Installation

How to Install Hasura GraphQL Engine

Hasura is an open-source GraphQL engine for PostgreSQL-based applications. It can connect to PostgreSQL, manage database access, configure event triggers, and expose GraphQL APIs. This guide covers both automatic deployment with a local PostgreSQL database and manual deployment with an external PostgreSQL database.

Automatic Deployment with Local PostgreSQL Database

1

Open Marketplace

Log in to the platform dashboard and click Marketplace at the top-left corner.

Marketplace button
Open Marketplace from the platform dashboard.
2

Install Docker Engine CE

Search for Docker Engine CE and start its installation.

Install Docker Engine CE
Find and start the Docker Engine CE installation.
3

Deploy Hasura and PostgreSQL from compose.yml

Select Deploy containers from compose.yml to create Hasura and PostgreSQL in the same container setup. Use the default Hasura Docker Compose configuration from the Hasura Docker repository.

https://raw.githubusercontent.com/hasura/graphql-engine/master/install-manifests/docker-compose/docker-compose.yaml
Deploy Hasura from compose.yml
Deploy Hasura and PostgreSQL together from the Hasura Docker Compose configuration.
!

Public IP is required

The documented automatic installation requires a public IP. The source documentation notes that this is a paid option available to billing users.

Configure the remaining Environment, Display Name, and Region fields as required, then click Install.

4

Open the Hasura console

After installation completes, open the Hasura console at:

http://{envDomain}:8080/console
Hasura admin panel
Open the Hasura console after successful deployment.

Use the Data tab to add or manage PostgreSQL data and then test GraphQL queries through the Hasura interface.

Manual Deployment with External PostgreSQL Database

If a PostgreSQL database already exists, Hasura can be deployed separately and connected to that external database.

1

Create a standalone Docker Engine CE

Install a clean standalone Docker Engine CE container from Marketplace.

Create clean Docker Engine CE
Create a standalone Docker Engine CE for an external PostgreSQL database.
2

Create the Hasura start script

Connect to the Docker container through Web SSH and create a file such as docker-run.sh.

docker run -d --restart=always -p 80:8080 \
-e HASURA_GRAPHQL_DATABASE_URL=postgres://{username}:{password}@{host}/{dbname} \
-e HASURA_GRAPHQL_ENABLE_CONSOLE=true \
-e HASURA_GRAPHQL_ADMIN_SECRET=myadminsecretkey \
hasura/graphql-engine:v1.0.0
Prepare Hasura installation command
Create the docker-run.sh script with the Hasura Docker command.

Docker Command Parameters

-dRuns the Hasura service in the background.
–restart=alwaysAutomatically starts the daemon again after a container restart.
-p 80:8080Redirects port 80 of the Docker Engine container to port 8080 of the Hasura image.
-eDefines environment variables for the Hasura container.
HASURA_GRAPHQL_DATABASE_URLPostgreSQL connection URL. Special characters in the URL must be URL-encoded. For a PostgreSQL database hosted on the platform, connection details are available in the database creation email.
HASURA_GRAPHQL_ENABLE_CONSOLEEnables the Hasura web console.
HASURA_GRAPHQL_ADMIN_SECRETDefines the admin secret used to protect access to the Hasura console. The source example uses myadminsecretkey.
hasura/graphql-engine:v1.0.0The Hasura Docker image used by the source tutorial.
3

Run the script

Make the script executable and execute it:

chmod +x docker-run.sh
./docker-run.sh
Install Hasura with custom configuration
Make the script executable and run it to create the Hasura container.

You can also run the following command to verify that the Hasura service is running:

docker ps

Access and Use the Hasura Console

In the source manual example, Hasura is exposed through port 80, so Open in Browser can redirect directly to the application. If another port is used, add the required port to the environment URL.

When prompted, enter the configured admin secret. In the source example:

myadminsecretkey
Hasura admin secret protection
Access the Hasura console with the configured admin secret.

You can now work with the connected PostgreSQL database through the GraphQL API, for example from the GraphiQL tab.

Existing PostgreSQL tables

If the database already contains tables, open the Data tab and enable tracking for the tables that Hasura should expose.

Track existing tables in Hasura
Track existing PostgreSQL tables from the Hasura Data tab.
Working in Hasura admin panel
Use the Hasura console and GraphiQL to work with the connected PostgreSQL database.

Alternatively, use the GraphQL Endpoint shown at the top of the Hasura page to send POST requests from another application, tool, or script.

Expected Result

Hasura GraphQL Engine is running either together with a local PostgreSQL database through Docker Compose or as a separate Docker container connected to an existing PostgreSQL database. The Hasura console is accessible, protected by an admin secret when configured, and can expose tracked PostgreSQL tables through GraphQL.

Important Notes

  • The source guide documents two deployment methods: automatic deployment with local PostgreSQL and manual deployment with external PostgreSQL.
  • The automatic Docker Compose deployment requires a public IP.
  • The documented automatic console URL uses port 8080.
  • Special characters in HASURA_GRAPHQL_DATABASE_URL must be URL-encoded.
  • The source manual example maps Docker port 80 to Hasura port 8080.
  • The source tutorial uses myadminsecretkey only as an example admin secret.
  • Existing PostgreSQL tables must be tracked from the Hasura Data tab before they are exposed through Hasura.
  • The source tutorial uses the Docker image hasura/graphql-engine:v1.0.0.