Railway

Deploy Strapi — Self-Hosted Headless CMS, Contentful Alternative

Self-host Strapi 5: headless CMS with REST & GraphQL. No $300/mo Contentful

Deploy Strapi — Self-Hosted Headless CMS, Contentful Alternative

/var/lib/postgresql/data

Just deployed

/public/uploads

Deploy and Host Strapi on Railway

Strapi headless CMS admin panel

Strapi is the most popular open-source headless CMS — 72k+ GitHub stars and the largest headless community — built on Node.js with a visual content-type builder that auto-generates REST and GraphQL APIs from your schema. Strapi 5 adds the Document Service API, content history and versioning, draft/publish workflows, a Vite-powered admin, and TypeScript-first projects. Model content in the browser, consume it from any frontend (Next.js, Astro, Vue, mobile), and own the whole stack. This template deploys Strapi 5 with PostgreSQL and a persistent volume.

Contentful's Team plan costs $300/month. Strapi self-hosted is free (MIT) — you pay only compute, ~$10–20/month on Railway. No per-seat fees, no API-call metering, no vendor lock-in; your content lives in your own PostgreSQL database.


What This Template Deploys

ServicePurpose
Strapi 5The headless CMS — content-type builder, admin panel, auto-generated REST + GraphQL APIs, on the public web service
PostgreSQL 16Production database — content, users, roles, and API tokens. Strapi requires SQL; Postgres is the production standard
Persistent VolumeMounted at /opt/app/public/uploads — media library files survive redeploys (or use S3/Cloudinary for scale)

All services connect over Railway's private network with credentials injected automatically. Using PostgreSQL (not SQLite) is deliberate and required: a SQLite file on an ephemeral container would lose all content on redeploy. This template wires Postgres correctly from the start.


About Hosting Strapi

Strapi is a Node.js app backed by a SQL database with a media library on disk. Production means a persistent server, PostgreSQL, media storage that survives restarts, and a public HTTPS endpoint. This template wires the app, Postgres, and a media volume on Railway automatically.

Two production requirements, both handled here: use PostgreSQL, not SQLite (SQLite is dev-only and non-persistent on cloud platforms), and persist media — Strapi's local file storage doesn't survive redeploys without a volume, so this template mounts one (use S3/Cloudinary for scale).

Security — keep it patched: Strapi disclosed serious vulnerabilities in May 2026 (unauthenticated admin access and SQL injection), patched in v5.33.2. Deploy a current patched version and keep it updated — self-hosted teams that delay updates carry real risk. Pin to a known-good tag rather than an unpinned latest.

Typical cost: ~$10–20/month on Railway for Strapi and PostgreSQL. Contentful's Team plan is $300/month; Strapi Cloud is $18–450/month. Self-hosted Strapi on Railway is flat compute with no license fee and no per-seat pricing.


Deploy in Under 5 Minutes

  1. Click Deploy on Railway — Strapi and PostgreSQL build automatically (~4–5 minutes)
  2. Database credentials and app secrets (APP_KEYS, JWT_SECRET) are auto-generated and wired
  3. Add a persistent volume at /opt/app/public/uploads so media survives redeploys
  4. Open [your-domain]/admin and create your first admin account (do this promptly to claim it)
  5. Build content types in the Content-Type Builder — your REST and GraphQL APIs generate instantly

No manual database setup. No Node server configuration. No SSL wrangling.


Common Use Cases

  • Self-hosted alternative to Contentful — replace the $300/month Team plan with flat compute; no API-call metering, no per-seat fees, and your content in your own database
  • Headless CMS for Next.js, Astro, or Vue — model content once, consume it via auto-generated REST or GraphQL from any modern frontend framework
  • Backend for a mobile app — serve structured content and media to iOS/Android from one CMS with role-based API tokens and permissions
  • Multi-channel content hub — deliver the same structured content to web, app, kiosk, and digital signage from a single API-first source of truth
  • Blog or marketing site CMS — give editors a clean admin panel with draft/publish, content history, and SEO fields via community plugins, without touching code
  • Developer-owned content layer — version content schemas in code and keep full control over data and infrastructure

Configuration

VariableRequiredDescription
DATABASE_CLIENT✅ Pre-setpostgres — the production database client
DATABASE_URL✅ Auto-injectedPostgreSQL connection string via Railway reference variable
APP_KEYS✅ Auto-generatedComma-separated app secrets for session signing
API_TOKEN_SALT✅ Auto-generatedSalt for API token generation
ADMIN_JWT_SECRET✅ Auto-generatedSecret for admin panel JWTs
JWT_SECRET✅ Auto-generatedSecret for content API JWTs
NODE_ENV✅ Pre-setproduction
HOSTPre-set0.0.0.0 — bind address
PORTAuto-setRailway injects the port; Strapi defaults to 1337

All four secrets (APP_KEYS, API_TOKEN_SALT, ADMIN_JWT_SECRET, JWT_SECRET) must be stable across redeploys — this template generates them once via reference variables. For media at scale, configure an S3 or Cloudinary upload provider instead of the local volume.


Strapi vs. Headless CMS Alternatives

Strapi (Railway)ContentfulSanityDirectus
Monthly cost~$10–20 flat$300/mo (Team)Usage-basedSelf-hosted
Self-hosted / own data✅ Yes❌ SaaS❌ SaaS✅ Yes
Visual content-type builder✅ Yes✅ Yes⚠️ Code (GROQ)✅ Yes
REST + GraphQL auto-generated✅ Both✅ Both⚠️ GROQ/GraphQL✅ Both
Plugin ecosystem✅ Largest⚠️ Apps⚠️ Growing⚠️ Smaller
Works with existing DB❌ Owns schema❌ No❌ No✅ Yes
Per-seat / API metering✅ None❌ Both❌ Usage✅ None
Open source✅ MIT❌ No❌ No✅ BSL

Dependencies for Strapi Hosting

  • Railway account — allocate 1–2 GB RAM for Strapi + Postgres (~$10–20/month)
  • A persistent volume for media, or an S3/Cloudinary account for scalable media storage
  • A frontend (Next.js, Astro, Vue, etc.) or app to consume the content APIs

Deployment Dependencies

Implementation Details

This template deploys Strapi 5 with PostgreSQL over Railway's private network — app secrets and the DB connection wired via reference variables, plus a persistent volume at /opt/app/public/uploads for media. Strapi requires SQL; Postgres is the production standard and SQLite is dev-only, so Postgres is used here.

The four security secrets are generated once and kept stable so sessions and API tokens survive redeploys. For media at scale, configure an S3 or Cloudinary provider — the local volume works for smaller sites but doesn't scale. Keep Strapi on a current patched version given the May 2026 security disclosures.


Frequently Asked Questions

How much does self-hosting Strapi save versus Contentful? Contentful's Team plan is $300/month, and costs climb with environments, locales, and API volume. Strapi self-hosted is free under MIT — you pay only ~$10–20/month Railway compute. For startups and small teams, that's a 70–90% saving versus commercial headless CMS platforms, with no per-seat or per-API-call fees.

Why PostgreSQL instead of SQLite? SQLite is fine for local development but is dev-only for Strapi in production — and on cloud platforms a SQLite file lives on an ephemeral container, so your content would vanish on redeploy. This template uses PostgreSQL, which persists your content independently of the app container. It's the production standard every Strapi guide recommends.

Do I lose my content or media if Railway redeploys? Content is safe — it's in the Railway-managed PostgreSQL database. Media is safe if you've mounted the persistent volume at /opt/app/public/uploads (or configured S3/Cloudinary). Without media persistence, uploaded files would be lost on redeploy, which is why this template includes a volume.

Does Strapi give me REST and GraphQL APIs? Yes. Strapi auto-generates REST endpoints from your content types, and installing the GraphQL plugin adds a GraphQL schema — both work simultaneously. Use whichever your frontend prefers; no manual API code required.

Is Strapi secure to run? Strapi is production-grade, but it disclosed serious vulnerabilities in May 2026 (patched in v5.33.2). Deploy a current patched version, pin to a known-good tag rather than latest, and keep it updated. Self-hosted teams that delay updates carry real risk — treat patching as routine.

Can I migrate from Contentful or another CMS? Yes, with effort. The content (JSON) is portable, but you recreate your content model in Strapi and migrate via API export/import, then update your frontend to Strapi's API structure. Budget a couple of weeks for a medium project and validate API responses before cutover.


Why Deploy and Host Strapi 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 Strapi on Railway, you get the most popular open-source headless CMS — visual content modeling, auto-generated REST and GraphQL APIs, and the largest plugin ecosystem — backed by PostgreSQL and persistent media storage at ~$10–20/month flat, with no per-seat fees and full ownership of your content.


Template Content

More templates in this category

View Template
Libredesk - Complete Setup
[Jul'26] Complete self-hosted omnichannel customer support desk.

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

Instatic
74
View Template
Strapi
A popular self-hosted CMS

Milo
7.6K