How to Deploy Your Cursor App to Railway
Deploy your Cursor-built Next.js or Node.js app to Railway with automatic deploys, environment variables, and custom domains.
Before you start
- ✓A Cursor project pushed to GitHub
- ✓A Railway account
Step by step
Push your code to GitHub
Make sure your Cursor project is connected to a GitHub repository with your latest changes pushed.
git add . && git commit -m 'Ready for deployment' && git push origin main
Create a Railway project
Go to railway.app and create a new project from your GitHub repo.
# railway.app → New Project → Deploy from GitHub Repo # Select your repository and branch
Configure environment variables
Add all your env vars in Railway → Variables. Copy them from your .env.local file.
# Railway → Your Service → Variables → Raw Editor # Paste all your environment variables here
Verify build settings
Railway auto-detects build commands, but verify they're correct for your project type.
# For Next.js: # Build: npm run build # Start: npm start # For Express/Node: # Build: npm install # Start: node server.js
Add a custom domain
Go to Settings → Networking → Custom Domain and add your domain.
# Add a CNAME record at your DNS provider: # Name: @ or www # Target: your-app.up.railway.app
Common errors
Build fails with memory error
The build process runs out of memory on Railway's free tier.
Fix: Add NODE_OPTIONS=--max-old-space-size=512 to your Railway environment variables.
Port not detected
Railway can't figure out which port your app listens on.
Fix: Add PORT to your env vars or use process.env.PORT in your server code. Railway assigns the port dynamically.
Deploy succeeds but app crashes
Missing environment variables cause runtime errors.
Fix: Compare your .env.local with Railway's Variables panel. All required vars must be present.