# app.py
from fastapi import FastAPI app = FastAPI() @app.get("/")
def read_root(): return {"message": "Hello from Railway!"} @app.get("/health")
def health(): return {"-weight: 500;">status": "ok"}
# app.py
from fastapi import FastAPI app = FastAPI() @app.get("/")
def read_root(): return {"message": "Hello from Railway!"} @app.get("/health")
def health(): return {"-weight: 500;">status": "ok"}
# app.py
from fastapi import FastAPI app = FastAPI() @app.get("/")
def read_root(): return {"message": "Hello from Railway!"} @app.get("/health")
def health(): return {"-weight: 500;">status": "ok"}
# requirements.txt
fastapi
uvicorn
# requirements.txt
fastapi
uvicorn
# requirements.txt
fastapi
uvicorn
# 1. Install Railway CLI
-weight: 500;">npm -weight: 500;">install -g @railway/cli # 2. Login
railway login # 3. Initialize project
railway init # 4. Deploy
railway up # 5. Open your app (Railway gives you a free .railway.app subdomain)
railway open
# 1. Install Railway CLI
-weight: 500;">npm -weight: 500;">install -g @railway/cli # 2. Login
railway login # 3. Initialize project
railway init # 4. Deploy
railway up # 5. Open your app (Railway gives you a free .railway.app subdomain)
railway open
# 1. Install Railway CLI
-weight: 500;">npm -weight: 500;">install -g @railway/cli # 2. Login
railway login # 3. Initialize project
railway init # 4. Deploy
railway up # 5. Open your app (Railway gives you a free .railway.app subdomain)
railway open
# Add PostgreSQL to your project
railway add --plugin postgresql # Your DATABASE_URL is automatically injected into your app
# Access it with:
import os
database_url = os.getenv("DATABASE_URL")
# Add PostgreSQL to your project
railway add --plugin postgresql # Your DATABASE_URL is automatically injected into your app
# Access it with:
import os
database_url = os.getenv("DATABASE_URL")
# Add PostgreSQL to your project
railway add --plugin postgresql # Your DATABASE_URL is automatically injected into your app
# Access it with:
import os
database_url = os.getenv("DATABASE_URL")
# server.js
const express = require('express');
const app = express();
const port = process.env.PORT || 3000; app.get('/', (req, res) => { res.json({ message: 'Hello from Railway!', environment: process.env.NODE_ENV });
}); app.listen(port, () => { console.log(`Server running on port ${port}`);
});
# server.js
const express = require('express');
const app = express();
const port = process.env.PORT || 3000; app.get('/', (req, res) => { res.json({ message: 'Hello from Railway!', environment: process.env.NODE_ENV });
}); app.listen(port, () => { console.log(`Server running on port ${port}`);
});
# server.js
const express = require('express');
const app = express();
const port = process.env.PORT || 3000; app.get('/', (req, res) => { res.json({ message: 'Hello from Railway!', environment: process.env.NODE_ENV });
}); app.listen(port, () => { console.log(`Server running on port ${port}`);
});
# package.json scripts
{ "scripts": { "-weight: 500;">start": "node server.js" }
}
# package.json scripts
{ "scripts": { "-weight: 500;">start": "node server.js" }
}
# package.json scripts
{ "scripts": { "-weight: 500;">start": "node server.js" }
}
# Example: Railway-hosted AI backend calling OpenClaw
import os
import requests OPENCLAW_API_KEY = os.getenv("OPENCLAW_API_KEY") def run_ai_task(prompt: str): response = requests.post( "https://api.openclaw.ai/v1/run", headers={"Authorization": f"Bearer {OPENCLAW_API_KEY}"}, json={"task": prompt} ) return response.json()
# Example: Railway-hosted AI backend calling OpenClaw
import os
import requests OPENCLAW_API_KEY = os.getenv("OPENCLAW_API_KEY") def run_ai_task(prompt: str): response = requests.post( "https://api.openclaw.ai/v1/run", headers={"Authorization": f"Bearer {OPENCLAW_API_KEY}"}, json={"task": prompt} ) return response.json()
# Example: Railway-hosted AI backend calling OpenClaw
import os
import requests OPENCLAW_API_KEY = os.getenv("OPENCLAW_API_KEY") def run_ai_task(prompt: str): response = requests.post( "https://api.openclaw.ai/v1/run", headers={"Authorization": f"Bearer {OPENCLAW_API_KEY}"}, json={"task": prompt} ) return response.json() - Languages: Node.js, Python, Go, Ruby, Rust, Java, PHP, Deno — auto-detected from your repo
- Frameworks: Next.js, FastAPI, Django, Flask, Express, Rails, Laravel
- Databases: PostgreSQL, MySQL, MongoDB, Redis — one-click provisioned
- Docker: Deploy any Dockerfile or public Docker image
- Cron jobs: Schedule tasks on a cron schedule, no extra setup
- Private networking: Services in the same project communicate privately - Go to railway.app and create an account
- Click New Project → Deploy from GitHub repo
- Select your repository
- Railway detects your stack and deploys automatically
- Every push to your main branch triggers a new deployment - Static website (no backend): Use Cloudflare Pages instead (actually free)
- Small Node.js API (256MB RAM, 0.1 vCPU): ~$2-3/month, covered by Hobby credits
- Python FastAPI + PostgreSQL: ~$4-6/month total
- Full-stack app (Node + Postgres + Redis): ~$8-12/month
- Background worker + cron jobs: ~$3-5/month - You need a backend -weight: 500;">service that’s always-on without cold starts
- You’re migrating from Heroku and want the same developer experience
- You want managed databases without the setup overhead
- You deploy multiple services that need to communicate (microservices)
- You want to avoid Docker configuration and just push code - You only need static hosting (use Cloudflare Pages — it’s free)
- You need a free backend that can tolerate cold starts (use Render)
- You need fine-grained control over infrastructure (use Fly.io or a VPS)
- Your app handles massive traffic (Railway scales, but cost scales too) - Render Free Hosting Review 2026: Deploy Web Apps, Databases, and Cron Jobs for Free
- Supabase vs Neon: Which Free PostgreSQL Database Should You Use in 2026?
- Vercel vs Netlify vs Cloudflare Pages: Free Frontend Hosting Compared
- Oracle Cloud Always Free: Get a 4-Core 24GB ARM VPS for Free
- 7 Best Free Web Hosting for Developers: Cloudflare Pages, Vercel, Netlify and More