This guide explains how to deploy BizManager's backend to Railway.app.
- A Railway.app account
- Your BizManager repository on GitHub
- Railway supports SQLite, but it's ephemeral (data will be lost on redeployments)
- For production, consider using Railway's PostgreSQL addon and migrating from SQLite
- Alternatively, use Railway for the backend and a persistent storage solution elsewhere
- Railway can host the backend API
- Deploy the frontend separately to Vercel, Netlify, or Cloudflare Pages
- See VERCEL_DEPLOYMENT.md for frontend deployment instructions
- Log in to Railway.app
- Click "New Project"
- Select "Deploy from GitHub repo"
- Choose your
bizmanagerrepository - Railway will automatically detect the configuration
After deployment, add these environment variables in Railway's dashboard:
| Variable | Value | Notes |
|---|---|---|
PORT |
5000 |
Railway will automatically set this, but you can override |
NODE_ENV |
production |
Set to production mode |
JWT_SECRET |
<your-secret> |
|
JWT_REFRESH_SECRET |
<your-secret> |
|
JWT_EXPIRES_IN |
15m |
Access token lifetime |
JWT_REFRESH_EXPIRES_IN |
7d |
Refresh token lifetime |
DB_PATH |
./database/bizmanager.db |
SQLite database path |
FRONTEND_URL |
https://your-frontend.vercel.app |
Your frontend URL for CORS |
To generate secure secrets:
node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"Railway will automatically:
- Run the
start.shscript - Install backend dependencies
- Initialize the
.envfile - Set up the SQLite database
- Start the backend server
Your API will be available at: https://your-app.up.railway.app
The following files enable Railway deployment:
The main deployment script that Railway executes. It:
- Installs backend dependencies
- Initializes environment configuration
- Sets up the database
- Starts the Node.js server
Railway-specific configuration:
[deploy]
startCommand = "bash start.sh"
restartPolicyType = "on_failure"
restartPolicyMaxRetries = 10Note: We use Railway's default Railpack builder, which automatically detects Node.js projects. The start.sh script handles all build and deployment steps.
Nixpacks configuration that explicitly installs Node.js:
[phases.setup]
nixPkgs = ["nodejs", "npm"]
[phases.install]
# Skip automatic install - start.sh handles it
[phases.build]
# Skip build phase - start.sh handles everything
[start]
cmd = "bash start.sh"Note: This file explicitly tells Nixpacks to install Node.js and npm as system packages during the setup phase. This ensures Node.js is available when start.sh runs. All application installation and setup is then handled by start.sh at runtime.
Cause: This error occurs when Railway's Railpack can't find the start.sh file.
Solution:
- Ensure
start.shis in the root directory - Verify it has executable permissions:
chmod +x start.sh - Check that the file is committed to your repository
Ephemeral Storage: Railway's filesystem is ephemeral. Data in SQLite will be lost on:
- Redeployments
- Service restarts
- Scaling events
Solutions:
-
Use Railway PostgreSQL:
- Add a PostgreSQL addon in Railway
- Modify the backend to use PostgreSQL instead of SQLite
- Update database connection code
-
Mount a Volume (Railway Pro):
- Use Railway's volume feature to persist SQLite
- Mount volume at
./backend/database
Symptom: "npm: command not found" or exit code 137 during build
Causes:
- Incorrect builder configuration causing npm to not be available
- Out of memory during npm install (exit code 137)
- Redundant build commands consuming too much memory
Solution:
- Use the simplified
railway.tomlwithout a custom build command - Let Railway's Railpack auto-detect the Node.js environment
- The
start.shscript usesnpm ci --omit=devto reduce memory usage - If still failing, upgrade to Railway Pro for more memory
Symptom: "Railpack could not determine how to build the app"
Solution:
- Ensure
start.sh,railway.toml, andProcfileare present - Verify
backend/package.jsonexists - Check that all scripts in package.json are valid
Symptom: Application fails to start or Railway shows "Application failed to respond"
Solution:
- Railway automatically sets the
PORTenvironment variable - The backend uses
process.env.PORT || 5000 - Ensure your code listens on
0.0.0.0, notlocalhost
If needed, modify backend/server.js:
app.listen(PORT, '0.0.0.0', () => {
console.log(`BizManager API running on port ${PORT}`);
});Symptom: Frontend can't connect to backend API
Solution:
- Set
FRONTEND_URLenvironment variable in Railway to your frontend URL - Example:
https://your-app.vercel.app - Ensure there's no trailing slash
- Redeploy after changing environment variables
- Open your Railway project
- Click on your service
- Navigate to "Deployments" tab
- Click on the latest deployment
- View real-time logs in the "Build Logs" and "Deploy Logs" tabs
Your backend includes a health check endpoint:
curl https://your-app.up.railway.app/api/healthExpected response:
{
"status": "ok",
"timestamp": "2026-03-31T08:20:00.000Z"
}┌─────────────────────────────────────────┐
│ Frontend (Vercel/Netlify/Cloudflare) │
│ React + Vite + Tailwind CSS │
│ https://your-app.vercel.app │
└─────────────┬───────────────────────────┘
│
│ HTTPS API Calls
│
┌─────────────▼───────────────────────────┐
│ Backend (Railway.app) │
│ Express.js + Node.js │
│ https://your-app.up.railway.app │
│ │
│ ┌────────────────────────────────┐ │
│ │ SQLite Database (Ephemeral) │ │
│ │ backend/database/bizmanager.db │ │
│ └────────────────────────────────┘ │
└──────────────────────────────────────────┘
For production deployments, migrate from SQLite to PostgreSQL:
- In Railway dashboard, click "New" → "Database" → "PostgreSQL"
- Railway will automatically create a PostgreSQL database
- Copy the
DATABASE_URLconnection string
cd backend
npm install pg
npm uninstall better-sqlite3Replace backend/database/db.js with PostgreSQL connection code (not covered in this guide).
Add to Railway environment variables:
DATABASE_URL: Your PostgreSQL connection string (automatically provided by Railway)
- Railway Free Tier: $5 worth of usage per month
- Typical usage: Small apps usually stay within free tier
- Monitor usage: Check Railway dashboard regularly
- Sleep after inactivity: Enable to reduce costs (app wakes on first request)
If you encounter issues:
- Check Railway's build and deployment logs
- Review this troubleshooting guide
- Check the Railway Discord for community support
- Open an issue on the BizManager GitHub repository