Deploy Directus
Turns any SQL database into a REST API, GraphQL API and admin app
directus
Just deployed
Just deployed
/var/lib/postgresql/data
Redis
Just deployed
/data
directus-storage
Bucket
Just deployed
Deploy and Host Directus on Railway
Directus is an open data platform that points at a SQL database and instantly gives you a REST API, a GraphQL API, and a no-code admin app called the Data Studio. Unlike most headless CMS tools it invents no storage format of its own: every collection is a real table, every field a real column, so the data stays queryable by anything else that reaches the database. Teams run it as a headless CMS, as an instant backend over an existing schema, and as an internal admin panel.
Self-host Directus on Railway with this template and you get the production shape upstream documents, not one container with a file beside it. The Directus service is public and terminates TLS at Railway's edge; managed PostgreSQL holds the schema and content; managed Redis backs the cache, the rate limiter, and the message bus behind realtime and collaborative editing; and a managed object-storage bucket holds uploaded files and Marketplace extensions. Every piece of shared state lives outside the container, so the app carries no volume and scales to more replicas without a config change.

Getting Started with Directus on Railway
Set ADMIN_EMAIL and ADMIN_PASSWORD at deploy time — they create the first administrator while the database initialises, and are the only inputs the template needs. When the deploy finishes, open the public URL; / redirects to /admin, the Data Studio sign-in screen, where you log in with those credentials.
On first login the Studio asks you to register a project owner for licence compliance and offers a licence key field; dismiss both if you are on the free Core plan, which needs no key. Then click Create Collection: name it, choose an ID type, add fields. It becomes a real PostgreSQL table on save, and GET /items/ plus a matching GraphQL type exist immediately — no build step, no redeploy.
To confirm the stack is wired up, add a few items and upload an image under File Library. A thumbnail that renders proves all three tiers at once: the database took the write, the bucket took the upload, and Directus read it back and transformed it. For a quick liveness check, GET /server/ping returns pong.

About Hosting Directus
Most teams need two things from one database: an API for developers and an editing interface for everyone else. Building either by hand takes weeks and is redone whenever the schema changes. Directus derives both from the schema, so adding a column adds an API field and a form input in one action. Self-hosting suits sensitive content, a database that cannot move, an API that belongs on your private network, or per-seat pricing that has stopped adding up.
- Instant REST and GraphQL APIs with filtering, sorting, aggregation, and relational queries
- The Data Studio, a no-code admin app with configurable layouts and content versioning
- Granular access control through roles, policies, and per-field permissions
- File storage with on-the-fly image transformation by query string
- Flows for automation, realtime over WebSockets, and Marketplace extensions
The Directus service runs the API and serves the Studio. PostgreSQL holds the system tables and your collections. Redis is what makes a second replica safe: shared cache, rate-limit counters, and the pub/sub bus keeping realtime sessions consistent. The bucket keeps uploads and extensions off the container filesystem.
Why Deploy Directus on Railway
Railway removes the infrastructure work around a multi-service stack:
- PostgreSQL, Redis, and object storage provisioned and wired up for you
- Private networking; only the app gets a public URL, TLS, and a domain
- Credentials are cross-service references, so nothing is copy-pasted
- Scaling to more replicas is a slider
Common Use Cases
- Headless CMS for a website or app — model pages, posts, and media, then fetch over REST or GraphQL from Next.js, Nuxt, Astro, or a mobile app
- Instant backend over an existing database — point Directus at a schema you already run and get an API plus admin UI for free
- Internal admin panel — a permissioned interface over production data for support or operations, with no custom tooling
Dependencies for Directus
- Directus —
directus/directus:latest, the API and Data Studio on port 8055 - PostgreSQL — Railway managed PostgreSQL 18, system tables and all content
- Redis — Railway managed Redis 8.2, cache, rate limiter, and realtime bus
- Object storage — a managed bucket for uploaded files and extensions
Environment Variables Reference
| Variable | Purpose |
|---|---|
SECRET | Signs sessions and tokens. Changing it logs everyone out. |
ADMIN_EMAIL / ADMIN_PASSWORD | Create the first administrator; read only while the database is empty. |
DB_CLIENT / DB_CONNECTION_STRING | PostgreSQL driver and connection string. |
CACHE_ENABLED / RATE_LIMITER_ENABLED / WEBSOCKETS_ENABLED | Cache, rate limiting, realtime. All off by default upstream. |
STORAGE_S3_* / EXTENSIONS_LOCATION | Point files and extensions at the bucket. |
NODE_OPTIONS | Caps the Node heap; lower it on a smaller container. |
Deployment Dependencies
- Source: https://github.com/directus/directus
- Image: https://hub.docker.com/r/directus/directus
- Self-hosting docs: https://directus.com/docs/self-hosting/overview
- Config reference: https://directus.com/docs/configuration/intro
Hardware Requirements for Self-Hosting Directus
| Resource | Minimum | Recommended |
|---|---|---|
| CPU | 0.25 vCPU | 1–2 vCPU |
| RAM | 512 MB | 2 GB |
| Storage | Database only | Database + object storage for uploads |
Image transformation is the memory-hungry part: if you serve many transformed assets, raise RAM before CPU and set NODE_OPTIONS to about half the container's RAM.
Self-Hosting Directus
The quickest local run uses SQLite inside the container, which is enough to look around. The following is a single Docker command:
docker run -p 8055:8055 \
-e SECRET=replace-with-a-long-random-string \
-e ADMIN_EMAIL=admin@example.com \
-e ADMIN_PASSWORD=choose-a-strong-password \
directus/directus:latest
A production stack adds PostgreSQL and Redis. The following is a Docker Compose file close to what this template deploys:
services:
database:
image: postgres:18
environment:
POSTGRES_USER: directus
POSTGRES_PASSWORD: directus
POSTGRES_DB: directus
volumes: ["./data/database:/var/lib/postgresql"]
cache:
image: redis:8
directus:
image: directus/directus:latest
ports: ["8055:8055"]
depends_on: [database, cache]
environment:
SECRET: replace-with-a-long-random-string
DB_CLIENT: pg
DB_HOST: database
DB_DATABASE: directus
DB_USER: directus
DB_PASSWORD: directus
REDIS: redis://cache:6379
CACHE_ENABLED: "true"
CACHE_STORE: redis
ADMIN_EMAIL: admin@example.com
ADMIN_PASSWORD: pick-a-strong-password
Railway replaces those three blocks with managed services and handles TLS, the domain, and health checks.
Is Directus Free to Self-Host?
Directus is source-available under the Monospace Sustainable Core License (MSCL-1.0-GPL), and each release additionally becomes GPL-3.0 four years after it ships. Self-hosting for your own use is a permitted purpose and costs nothing in licence fees; the licence restricts offering Directus itself to others as a competing paid service. The free Core plan is metered — at the time of writing 3 seats, 25 collections, 5 flows, and no SSO — with paid plans lifting those limits; check the live figures at GET /license. On Railway you pay only for the infrastructure the stack uses.
FAQ
What is Directus?
An open data platform that wraps any SQL database in a REST API, a GraphQL API, and a no-code admin app. It stores data as plain tables and columns, so the database stays usable by other tools too.
What does this Railway template deploy?
The Directus app on a public URL, managed PostgreSQL, managed Redis, and an object-storage bucket for uploads and extensions, wired together over private networking.
Why does the template include Redis if Directus runs without it?
Redis is optional for one container and required the moment you run two. It holds the shared cache, the rate-limit counters, and the pub/sub bus behind realtime, so raising replicas needs no config change.
Why object storage instead of a volume for uploads?
A Railway volume attaches to exactly one service, so it would cap the app at one replica and tie your files to that container's disk. The bucket holds uploads and Marketplace extensions, keeping the app stateless.
How do I connect a Next.js or Nuxt frontend to self-hosted Directus?
Create an access token or a dedicated user under Settings → Access Policies, then query https:///items/ with an Authorization: Bearer header, or use the official @directus/sdk package. For public content, grant read to the Public policy and drop the token.
Template Content