DEV Community

Terry Leonard Hunt Jr
Terry Leonard Hunt Jr

Posted on • Originally published at terryhunt.dev

Deploy Your Own Strapi CMS to Railway (No Templates Needed)

๐Ÿš€ How to Set Up Strapi Locally and Deploy to Railway (The Easy Way)

Want to build and deploy your own Strapi CMS without touching Docker or overcomplicating things? Here is how you can go from local development to a live app on Railway with no one-click templates needed.


๐Ÿ†š Quick Note: Strapi Cloud vs Railway

Strapi offers their own free tier cloud hosting:
๐Ÿ‘‰ https://strapi.io/pricing-cloud

But many developers prefer Railway for full control over:

  • your Strapi app
  • your data
  • your file system
  • your deployments
  • your database choices

If that sounds like your style, try Railway here:
๐Ÿ‘‰ https://railway.com?referralCode=ps81C1


1. ๐Ÿง‘โ€๐Ÿ’ป Set Up Strapi on Your Local Machine

Step 1: Install Strapi CLI

npm install -g create-strapi-app
Enter fullscreen mode Exit fullscreen mode

Step 2: Create Your Project

npx create-strapi-app@latest my-strapi-project --quickstart
Enter fullscreen mode Exit fullscreen mode

This spins up a new Strapi app and launches it at:
http://localhost:1337

๐Ÿ’ก Tip: When prompted to create an admin user in the browser, go ahead and do that now.

Step 3: Test and Tweak

Add your content types, explore the admin panel, and make sure everything works as expected.

When finished, stop the server:

ctrl + c
Enter fullscreen mode Exit fullscreen mode

2. ๐Ÿงณ Prepare Your Project for Railway

Step 1: Add Environment Configs

Create a .env file in your project root:

DATABASE_CLIENT=sqlite
NODE_ENV=production
PORT=1337
APP_KEYS=someLongAppKey1,someLongAppKey2
API_TOKEN_SALT=randomStringHere
ADMIN_JWT_SECRET=randomSecretHere
JWT_SECRET=anotherSecretHere
Enter fullscreen mode Exit fullscreen mode

๐Ÿ” Use https://randomkeygen.com to generate secure values.

Step 2: Update package.json Scripts

Ensure your scripts section includes:

"scripts": {
  "develop": "strapi develop",
  "start": "strapi start",
  "build": "strapi build",
  "strapi": "strapi"
}
Enter fullscreen mode Exit fullscreen mode

Step 3: Push to GitHub

git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/your-username/your-repo.git
git push -u origin main
Enter fullscreen mode Exit fullscreen mode

3. ๐Ÿšข Deploy to Railway

Step 1: Connect Your GitHub Repo

  1. Go to Railway: https://railway.com?referralCode=ps81C1
  2. Create a new project
  3. Select Deploy from GitHub Repo
  4. Choose your Strapi repository

Step 2: Set Environment Variables

Go to Railwayโ€™s Variables tab and add the same values you put in your .env file.

โš ๏ธ Your app will not deploy correctly without these secrets.

Step 3: Trigger the Deployment

Railway detects it is a Node.js project and automatically runs:

  • npm run build
  • npm start

Once deployed, you will get a live URL in the Deployments tab ๐ŸŽ‰


4. โœ… Final Touches

  • ๐Ÿ“ฆ Prefer PostgreSQL over SQLite? Add Railwayโ€™s PostgreSQL plugin and update your .env.
  • โ˜๏ธ Want persistent media uploads? Use a Strapi upload provider such as S3 or Cloudinary: https://docs-v4.strapi.io/dev-docs/plugins/upload/
  • ๐Ÿ” If exposing APIs, configure CORS plus roles and permissions.

๐ŸŽฏ Thatโ€™s It

You have now built and deployed a Strapi CMS, fully customized and not locked into any presets.

Try Railway:
๐Ÿ‘‰ https://railway.com?referralCode=ps81C1

Curious about Strapi Cloud? Explore it here:
๐Ÿ‘‰ https://strapi.io/pricing-cloud

Top comments (0)