Deploy
Railway vs Vercel for Beginners
Railway and Vercel are both popular with first-time deployers — and choosing the wrong one causes confusing errors that have nothing to do with your code quality. They solve different problems. Vercel excels at frontends and Next.js. Railway excels at long-running backends, databases, and Python. This guide helps you pick confidently, explains the common split-host pattern for full-stack apps, gives honest notes on free tiers without overpromising, and walks through a decision flow you can follow in five minutes.
Updated July 2026 · 10 min read
Written for AI makers using tools like Cursor, Bolt, Lovable, Replit, Claude, and ChatGPT.
Quick answer
Use Vercel for Next.js frontends and static React/Vite sites. Use Railway for Django, FastAPI, Flask, and Node APIs that run continuously, plus PostgreSQL. Full-stack apps often use both: Vercel for the UI, Railway for the API and database. Wrong-host errors include DisallowedHost on Django deployed to Vercel, or expecting serverless to run a persistent Python worker.
Who this is for
- You are about to deploy your first app and cannot tell which platform to sign up for
- You deployed to Vercel and your Django or FastAPI app fails in confusing ways
- You have a frontend and backend in one repo and need a sane hosting split
What you'll need
- Rough idea of your stack (check
package.json,manage.py, orDockerfilein your repo) - GitHub repo with your project code
- Ten minutes to read this guide before creating hosting accounts
What Vercel and Railway actually do
Vercel is a frontend cloud optimized for Jamstack and Next.js. It builds your site, serves static assets from a global CDN, and runs serverless functions for API routes with strict time and memory limits. It is not designed to run a Django process listening on a port 24/7.
Railway is a general-purpose app host. It builds containers from your GitHub repo, runs long-lived processes (gunicorn, node server.js, uvicorn), and offers add-on databases like PostgreSQL. It behaves more like a traditional server — without you managing Linux yourself.
Both connect to GitHub and redeploy on push. Both have dashboards for environment variables. The difference is what kind of process they expect to run after the build finishes.
Neither replaces the other for every app. Many production teams use both simultaneously.
When Vercel wins
Next.js is the clearest Vercel case. Framework detection, incremental static regeneration, middleware, and edge functions are first-class. If your AI tool generated a create-next-app project, start with Vercel unless you have a strong reason not to.
Static React + Vite SPAs also deploy cleanly on Vercel. Build to dist/, serve from CDN — fast and cheap for frontend-only projects.
Marketing sites, landing pages, documentation, and portfolios fit Vercel well. Low operational overhead, automatic HTTPS, preview URLs per branch.
Choose Vercel when your backend logic lives inside Next.js API routes or Route Handlers and stays within serverless limits (short requests, no WebSocket servers, no heavy background workers).
- Next.js (App Router or Pages Router)
- React + Vite static SPAs
- Frontend-heavy apps with light serverless APIs
- You want the fastest path from GitHub to a public URL for a JS frontend
When Railway wins
Django is the canonical Railway app. You need gunicorn running continuously, PostgreSQL, migrations, and static files via WhiteNoise. Railway provides DATABASE_URL when you add Postgres — Vercel does not natively host this pattern for beginners.
FastAPI, Flask, Express APIs, and custom Node servers that listen on a PORT variable belong on Railway (or similar: Render, Fly.io). These are persistent processes, not ephemeral serverless invocations.
Background workers, cron jobs, queue consumers, and WebSocket servers need a always-on host. Railway supports multiple services in one project — web + worker + database.
Choose Railway when your repo root has manage.py, a Procfile with gunicorn, or a main.py running uvicorn — not when it only has a Vite frontend.
- Django, FastAPI, Flask Python backends
- PostgreSQL or Redis in the same project
- Long-running Node or Python servers
- Monorepo where the primary app is a backend API
Full-stack split patterns
The most common production pattern for AI-built full-stack apps: Vercel hosts the React or Next.js frontend; Railway hosts the Django/FastAPI API and PostgreSQL database. The frontend reads import.meta.env.VITE_API_URL or NEXT_PUBLIC_API_URL pointing at the Railway URL.
Monorepo layout often looks like /frontend and /backend folders. Create two deploy projects — one on Vercel (root: frontend), one on Railway (root: backend). Each has its own environment variables and build commands.
Single-framework full-stack on Next.js can stay entirely on Vercel if database access uses a hosted service (Supabase, PlanetScale, Neon) via server-side env vars — no separate Railway service needed.
Single-repo Django with templates (no separate SPA) can live entirely on Railway. You do not need Vercel at all for server-rendered Django HTML.
Avoid deploying the same Python backend to both platforms 'just in case' — pick one API host and one frontend host. Double deploys double confusion.
Cost and free tier — honest notes
Free tiers change. Do not build your business plan around today's limits — check vercel.com/pricing and railway.com/pricing before you launch.
Vercel Hobby (free) suits personal and small projects with bandwidth and serverless execution caps. Commercial use may require a paid plan depending on current terms. Preview deployments and HTTPS are included.
Railway historically offered trial credits for new accounts rather than unlimited forever-free hosting. Small apps with one web service and a modest Postgres instance often cost a few dollars per month after credits expire. Budget accordingly — 'free' may mean 'cheap to start,' not 'free forever at scale.'
Database storage and egress add cost on both platforms as you grow. For learning and MVPs, both are affordable. For high-traffic production, plan paid tiers early.
Do not choose a host only because it is free. Choose because your stack fits. A wrong host costs more in debugging time than a $5 monthly bill.
Decision flowchart (follow in order)
Start here: open your repo root. Do you see manage.py or a Python WSGI/ASGI app as the main entry point? If yes → Railway for that service. Skip Vercel for the Python part.
Do you see next in package.json with an app/ or pages/ directory as the main product? If yes → Vercel for that service. Add Railway only if you also have a separate Python backend folder.
Do you see only vite.config.ts and a React src/ folder with no backend in the repo? If yes → Vercel or Netlify for static deploy. Add Railway later only when you deploy a separate API.
Does your app need PostgreSQL that you manage yourself (not Supabase hosted)? If yes → Railway (or Render) for the database plus backend. Vercel connects to external databases but does not provision Postgres for you.
Still unsure? Describe your stack to your AI editor: 'Given this package.json and folder structure, should I use Vercel, Railway, or both?' Paste the answer into a launch checklist before signing up.
Common wrong-host errors
Django on Vercel: build may succeed but requests fail or timeout because Vercel expects serverless handlers, not gunicorn. Fix: move Django to Railway.
DisallowedHost on Railway: you deployed Django correctly but forgot ALLOWED_HOSTS — not a platform mismatch, but beginners often blame the host. Add your *.railway.app domain.
Next.js API routes with 10-second timeouts: heavy ML inference or long DB migrations in a serverless function exceed Vercel limits. Move heavy work to Railway background worker or optimize.
Vite SPA on Railway without a static server config: Railway expects a process. A raw dist/ folder needs npx serve or similar — easier to use Vercel/Netlify for pure static.
CORS errors after split deploy: frontend on Vercel, API on Railway, but backend only allows localhost. Update CORS allowed origins to your Vercel domain.
SQLite in production on Railway: containers restart and lose local SQLite files. Use Railway PostgreSQL instead.
Using both together (recommended for many AI apps)
Deploy order matters: backend first. Get Railway API URL live, run migrations, test /health or /api endpoint with curl. Then set VITE_API_URL or NEXT_PUBLIC_API_URL on Vercel and deploy the frontend.
Keep environment variables separated. Railway holds DATABASE_URL, SECRET_KEY, Django settings. Vercel holds public frontend vars and any Next.js server secrets for server components.
Custom domains: api.yourdomain.com on Railway, yourdomain.com on Vercel. Update CORS, ALLOWED_HOSTS, and OAuth callbacks on both sides when domains change.
One GitHub repo, two deploy hooks — totally normal. Each platform watches the same repo but different root directories or branch filters if configured.
Step-by-step
- 1
Step 1
Identify your primary stack
List frameworks in your repo: Next.js, Vite React, Django, FastAPI, etc. Note which folder is frontend vs backend in monorepos.
- 2
Step 2
Apply the decision flow
Python backend → Railway. Next.js or static frontend → Vercel. Both present → split deploy.
- 3
Step 3
Create accounts and projects
Sign up only for what you need today. Import the same GitHub repo into each platform with correct root directory settings.
- 4
Step 4
Deploy backend before frontend
Railway first: database, env vars, migrations, API smoke test. Then Vercel with API URL in frontend env vars.
- 5
Step 5
Run a launch checklist
Verify CORS, auth callbacks,
ALLOWED_HOSTS, and end-to-end flows on production URLs — notlocalhost.
Common mistakes
Deploying Django to Vercel because it is 'more popular'
How to fix it: Use Railway for Django. Vercel is for frontends and Next.js — not WSGI apps without major rework.
Expecting unlimited free hosting forever on either platform
How to fix it: Check current pricing and trial credits. Budget for low monthly cost as soon as you have real users.
Deploying frontend before the API exists
How to fix it: Backend first, then set
VITE_API_URLorNEXT_PUBLIC_API_URL, then build and deploy frontend.One env file for both platforms
How to fix it: Railway and Vercel dashboards are separate. Copy only relevant vars to each —
DATABASE_URLon Railway,NEXT_PUBLIC_vars on Vercel.Ignoring monorepo root directory settings
How to fix it: Tell Vercel the frontend subfolder. Tell Railway the backend subfolder. Default repo root deploys the wrong app.
Copy-ready prompt
Prompt: choose Railway, Vercel, or both
Paste this into Cursor, Claude, ChatGPT, Bolt, Lovable, or your AI coding tool.
Ready to paste
Look at this repository structure and dependencies. Recommend a hosting strategy for a beginner. 1. Is the primary app Next.js, Vite React, Django, FastAPI, or something else? 2. Should I use Vercel, Railway, Netlify, or a combination? 3. If full-stack, what is the recommended split (which service on which host)? 4. What environment variables go on each platform? 5. What is the correct deploy order? 6. List common misconfigurations if I pick the wrong host. Be specific to this repo's folders and package files. Do not recommend Django on Vercel for a beginner.
Paste this into Cursor, Claude, ChatGPT, Bolt, Lovable, or your AI coding tool.
Ready check
Beginner checklist
- Stack identified (frontend framework + backend if any)
- Hosting choice matches stack — not just which platform is trending
- Monorepo root directories configured per platform
- Railway project for API/database (if Python backend)
- Vercel project for Next.js or Vite frontend (if applicable)
- Backend deployed and API URL confirmed before frontend build
- CORS and
ALLOWED_HOSTSinclude production domains - Pricing pages reviewed — no surprise bills expected at MVP scale
- End-to-end test passed on production URLs
Frequently asked questions
- Can I host everything on Vercel?
- Frontends and Next.js full-stack apps with external hosted databases — yes. Django, FastAPI, and always-on Python servers — not as a beginner path. Use Railway for those.
- Can I host everything on Railway?
- Backends and databases — yes. Static Vite SPAs work but Vercel/Netlify are simpler for pure frontend. Next.js on Railway is possible but loses Vercel's Next.js optimizations.
- Do I need both platforms for a Cursor-built app?
- Only if your app has both a JS frontend and a separate Python/Node backend. A pure Next.js Cursor project needs only Vercel. A Django API + React frontend needs Railway + Vercel (or similar split).
- Which has a better free tier?
- Neither is universally 'better' — limits differ by usage type. Vercel Hobby works for many frontends. Railway uses usage-based pricing with trial credits. Check current docs before deciding.
- I already deployed to the wrong host — do I start over?
- Usually you create a new project on the correct host and redeploy from the same GitHub repo. You rarely need to rewrite code — just move the service and fix env vars, CORS, and
ALLOWED_HOSTS.