Deploy Directus

Directus [Oct '26] (Headless CMS/Strapi & Supabase Alternative) Self Host

Deploy Directus

Just deployed

/data

Just deployed

Just deployed

/var/lib/postgresql/data

Bucket

Bucket

Just deployed

Deploy and Host Directus on Railway (self hosted headless CMS and SQL API)

Directus is an open source data platform that turns any SQL database into a REST and GraphQL API, with a full admin app (the Directus Data Studio) on top. Unlike most headless CMS tools, Directus does not own your data model: it introspects the tables you already have, keeps your schema clean and lets you walk away without a migration. This template deploys self hosted Directus on Railway with S3-compatible file storage and optional WebSockets (realtime) already wired.

About Hosting Directus (Directus Docker, self hosted)

Self hosting Directus means running the official directus/directus Docker image next to a SQL database, with persistent file storage, a public URL and the right environment variables. On a VPS you manage Docker, reverse proxy, TLS, backups and upgrades yourself. On Railway, this template provisions Directus and its database, connects them over the private network, generates secrets and exposes Directus on an HTTPS domain.

This template includes Directus, PostgreSQL, Redis and an S3-compatible bucket for file storage, all connected at deploy time.

Why Deploy Directus on Railway

You run the open source Directus and pay only for the resources your instance uses, with no per-seat or per-project fees and no server to maintain. A project that is idle most of the day costs very little.

ProviderWith RailwayWith the other provider
VPS (Hetzner, DigitalOcean)One-click Directus with database and HTTPSYou set up Docker, proxy, TLS and backups
AWS / GCPNo IAM, VPC or load balancer setupMaximum flexibility, much higher complexity
Directus CloudOpen source Directus at infrastructure costFully managed, priced per project with plan limits

Common Use Cases for self hosted Directus

  • Instant REST and GraphQL API for a PostgreSQL or MySQL database you already have.
  • Headless CMS for Next.js, Nuxt, Astro, SvelteKit or mobile apps.
  • Admin panel and back office so non-technical teammates edit production data with granular permissions.
  • Internal tools that would otherwise be a custom CRUD app.
  • Digital asset management with bucket storage and on-the-fly image transformations.
  • Realtime apps using WebSocket subscriptions.
  • Automation with Directus Flows (webhooks, emails, scheduled jobs).

Dependencies for Directus Hosting

Deployment Dependencies

  • PostgreSQL (recommended). Directus also supports MySQL, MariaDB, SQLite, SQL Server, OracleDB and CockroachDB.
  • File storage: an S3-compatible bucket, included in this template.
  • Redis (optional) for shared cache when running more than one instance.

Implementation Details (environment variables)

VariablePurpose
SECRETSigns tokens. Never change it after launch
DB_*Database connection, wired automatically
ADMIN_EMAIL, ADMIN_PASSWORDSeed the first admin on first boot only
PUBLIC_URLPublic URL used in links and OAuth
STORAGE_LOCATIONSlocal or s3
WEBSOCKETS_ENABLEDEnables realtime
CORS_ENABLED, CORS_ORIGINAllow your frontend to call the API

Directus vs other headless CMS and backends

Directus vs Strapi: Strapi creates its own tables from content types. Directus works on any existing schema, so it fits databases that already have data.

Directus vs Supabase: Supabase is a backend-as-a-service around its own Postgres. Directus is a data layer and admin app for any SQL database, with an interface built for non-technical editors.

Directus vs Payload: Payload is code-first inside a Next.js app. Directus is database-first and runs as an independent service any frontend can consume.

Directus vs Contentful and Sanity: both are hosted and priced by seats and usage. Self hosted Directus keeps data in your database with no seat or API limits.

Directus features explained

  • Data Studio: no-code app to browse, filter and edit any table, with table, card, calendar, map and kanban layouts.
  • REST and GraphQL APIs generated from your schema and kept in sync automatically.
  • Roles and permissions down to individual fields and row-level conditions.
  • Authentication: local login, OAuth 2.0, OpenID Connect, LDAP and SAML.
  • Image transformations: resize, crop and convert images through query parameters.
  • Flows for event-driven and scheduled automation, and Insights for dashboards.
  • Extensions: custom interfaces, endpoints, hooks and modules, plus a community marketplace.

Directus S3 storage (uploads that survive redeploys)

Container filesystems are ephemeral, so Directus deployments that store uploads locally lose every file on redeploy. This is the most common problem with Directus on any PaaS. This template avoids it: uploads go to the S3-compatible bucket included in the project, already connected to Directus, so files persist across redeploys and scale independently from the Directus service.

Directus WebSockets and realtime setup

Realtime is disabled by default. Set WEBSOCKETS_ENABLED=true, then subscribe through the Directus SDK or at wss://your-domain/websocket to receive create, update and delete events without polling. Realtime follows the same permissions as the REST and GraphQL APIs.

How to use Directus after deploying

  1. Open the public domain of the Directus service.
  2. Log in with ADMIN_EMAIL and ADMIN_PASSWORD, then change the password.
  3. Create collections in Settings → Data Model or use tables that already exist.
  4. Set access in Settings → Access Policies.
  5. Call https://your-domain/items/your_collection or GraphQL at /graphql.

Is Directus free? (license and pricing)

Directus uses the Business Source License (BSL 1.1). Self hosting is free for individuals and organizations under $5M in annual revenue and funding; larger organizations need a commercial license. Directus Cloud is the managed option, priced per project.

Monthly cost of self hosting Directus on Railway

A typical project (Directus plus PostgreSQL, moderate traffic) costs around $3 per month with usage-based billing. 1 vCPU and 1 GB of RAM is a comfortable starting point.

Troubleshooting self hosted Directus

Uploads disappear after redeploy: check that STORAGE_LOCATIONS still points to the bucket. Local storage is wiped on every deploy.

CORS errors: set CORS_ENABLED=true and CORS_ORIGIN to your frontend domain.

Changing ADMIN_PASSWORD does nothing: it only seeds the first admin. Change it in the Data Studio.

Everyone logged out after redeploy: SECRET changed. Keep it constant.

Schema from staging to production: use npx directus schema snapshot and npx directus schema apply.

Frequently Asked Questions (FAQs)

Can Directus connect to a database I already have? Yes. It introspects existing tables without migrating your data.

Is Directus free to self host? Yes, for individuals and organizations under $5M in annual revenue and funding.

Does Directus support GraphQL and realtime? Yes. REST and GraphQL are generated automatically, and realtime works over WebSockets.

Which databases does Directus support? PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, OracleDB and CockroachDB.

How do I keep uploaded files when redeploying Directus? This template already stores them in an S3-compatible bucket, so they persist across redeploys.

Is Directus a good Strapi alternative? Yes, especially if you already have a database or want full ownership of your schema.

How do I upgrade Directus on Railway? Back up the database, update the image tag and redeploy. Migrations run automatically on start.

Related templates

[Updated Oct '26]


Template Content

More templates in this category

View Template
Libredesk - Complete Setup
Complete self-hosted omnichannel customer support desk.

codestorm
2
View Template
Paperless-ngx
Paperless-ngx — document management with OCR and full-text search

INAPP
1
View Template
Instatic CMS - Postgres
Design, build and manage powerful static sites from state-of-the-art CMS

Instatic
167