Deploy & Host Dgraph | Railway

Deploy and Host Dgraph on Railway

Dgraph is a distributed, open-source graph database with a native GraphQL API and its own query language, DQL. It stores data as a graph of nodes and edges, supports full-text, geo and vector indexes, and runs fast traversals and joins, which suits social graphs, knowledge graphs and recommendation engines.

About Hosting Dgraph

This template deploys Dgraph v25.4.1 as a Zero node, which runs cluster coordination, and an Alpha node, which stores and serves data, each with its own Railway volume, plus a Caddy gateway as the public entry point. The gateway requires a bearer token and removes it before forwarding. Schema changes and other admin operations additionally need the Alpha admin token in the X-Dgraph-AuthToken header. Data survived redeploys of both nodes in testing. The gRPC API stays private. Memory use grows with dataset size; start on Hobby and scale up. Back up both volumes regularly.

Common Use Cases

Dependencies for Dgraph Hosting

Deployment Dependencies

Implementation Details

Service Image Networking Storage
zero dgraph/dgraph:v25.4.1 private only (5080, 6080) volume at /dgraph
alpha dgraph/dgraph:v25.4.1 private: HTTP 8080, gRPC 9080 volume at /dgraph
gateway caddy:2.11.4-alpine public domain on 8080 none
# GraphQL schema (admin)
curl -X POST "$DGRAPH_URL/admin/schema" -H "Authorization: Bearer $DGRAPH_API_TOKEN" \
  -H "X-Dgraph-AuthToken: $DGRAPH_ADMIN_TOKEN" --data-binary 'type Task { id: ID! title: String! @search(by: [term]) }'
# GraphQL
curl -X POST "$DGRAPH_URL/graphql" -H "Authorization: Bearer $DGRAPH_API_TOKEN" \
  -H "Content-Type: application/json" -d '{"query": "{ queryTask { title } }"}'

Services on Railway can use ${{alpha.DGRAPH_PRIVATE_HTTP}} or gRPC ${{alpha.DGRAPH_PRIVATE_GRPC}} without the gateway token.

Variable Service Default Purpose
DGRAPH_API_TOKEN gateway generated Bearer token for all public requests
DGRAPH_ADMIN_TOKEN alpha generated Required for admin operations

Notes:

This is a community-maintained deployment package and does not imply affiliation with or endorsement by the Dgraph project or its maintainers.

Why Deploy Dgraph on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Dgraph on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.