Railway Deployment Doctor
Diagnose Railway deployment issues before you deploy
A CLI tool that scans your project and identifies common Railway deployment problems BEFORE you deploy. Think of it as a pre-flight checklist that catches mistakes early and saves you debugging time.
The Problem
Deploying to Railway often fails due to common, preventable configuration issues:
- Hardcoded ports instead of using
process.env.PORT
- Binding to
localhost instead of 0.0.0.0
- Missing or incorrect start scripts
- Development tools in production scripts
Railway Doctor catches these issues locally in seconds, with actionable fix suggestions.
Features
- Framework-agnostic - Works with ANY Node.js or Python project, not just known frameworks
- Fast scanning - Analyzes your entire project in under 1 second
- Multi-file analysis - Scans all source files, not just entry points
- Framework detection - Automatically detects 10+ frameworks (SvelteKit, Remix, Next.js, Django, and more)
- Actionable fixes - Shows exact before/after code with line numbers
- 5 comprehensive checks:
- PORT configuration (process.env.PORT usage)
- Host binding (0.0.0.0 requirement)
- Start command validation
- Environment variables detection
- Database connection validation
- Multiple output formats - Human-friendly terminal output or JSON for CI/CD
Installation
Install globally with npm:
npm install -g railway-doctor
Or use directly without installing (via npx):
npx railway-doctor scan
With Bun:
bunx railway-doctor scan
For Development
To contribute or run from source:
git clone https://github.com/wsoule/railway-doctor
cd railway-doctor
bun install
bun run src/cli.ts scan
Usage
Scan a project
railway-doctor scan
railway-doctor scan ./my-project
railway-doctor scan --verbose
railway-doctor scan --json
Using npx (no installation required):
npx railway-doctor scan
npx railway-doctor scan ./my-project
Example Output
Railway Deployment Doctor
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Framework detected: express
Entry point: server.js
[ERROR] Found 3 errors
[X] Hardcoded port 3000. Railway requires process.env.PORT
File: server.js:5
Fix: Use process.env.PORT with a fallback for local development
- const port = 3000;
+ const port = process.env.PORT || 3000;
[X] App binds to localhost/127.0.0.1, which won't work on Railway
File: server.js:12
Fix: Bind to 0.0.0.0 to accept external connections
- app.listen(port, 'localhost')
+ app.listen(port, "0.0.0.0")
[X] No "start" script found in package.json
File: package.json
Fix: Add start script for Express
+ "scripts": {
+ "start": "node server.js"
+ }
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Summary
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Total checks: 3
Passed: 0
Warnings: 0
Errors: 3
Deployment Likelihood: WILL FAIL
Fix the 3 errors above before deploying.
Supported Frameworks
Railway Doctor now works with ANY Node.js or Python project, not just specific frameworks!
Fully Supported with Framework-Specific Checks:
- SvelteKit - Full support for modern Svelte apps
- Remix - Full support for Remix apps
- Astro - Full support for Astro sites
- Nuxt - Full support for Nuxt.js apps
- Next.js - Full support with framework-specific checks
- Express.js - Full support with framework-specific checks
- NestJS - Full support with framework-specific checks
- Django - Full support (ALLOWED_HOSTS, whitenoise, gunicorn, DATABASE_URL, CSRF_TRUSTED_ORIGINS)
- Flask - Full support (gunicorn, Procfile, production server checks)
- FastAPI - Full support (uvicorn, Procfile, production server checks)
Generic Support:
Even if your framework isn't listed above, Railway Doctor will still scan your project for:
- Hardcoded ports and missing
process.env.PORT usage
- Incorrect host binding (localhost vs 0.0.0.0)
- Missing start/build scripts
- Environment variable usage
- Database configuration issues
This means it works with Hono, Elysia, Koa, Fastify, SolidStart, Qwik, and any other Node.js/Python framework!
What It Checks
1. PORT Configuration
- Detects hardcoded ports (3000, 8000, etc.)
- Ensures
process.env.PORT is used
- Framework-specific checks (Next.js
--port flag, etc.)
2. Host Binding
- Detects localhost/127.0.0.1 binding
- Ensures 0.0.0.0 binding for Railway
- Framework-specific checks (Next.js
--hostname flag)
3. Start Command
- Validates "start" script exists in package.json
- Detects development tools in production (nodemon, ts-node-dev)
- Ensures build scripts exist for Next.js/NestJS
- Python: Checks for Procfile and production servers (gunicorn/uvicorn)
4. Environment Variables
- Scans code for
process.env.* references
- Detects env var usage in Python (os.environ)
- Checks if .env is properly in .gitignore
- Lists all env vars that should be set in Railway
5. Database Configuration
- Detects database libraries (PostgreSQL, MySQL, MongoDB, Prisma, etc.)
- Flags localhost/127.0.0.1 database connections
- Checks for Unix socket connections (won't work on Railway)
- Verifies DATABASE_URL env var usage
- Suggests Railway database service integration
Framework-Specific Checks
Django:
- ALLOWED_HOSTS validation (must include Railway domains or *)
- Whitenoise static files middleware configuration
- DEBUG setting (should be False in production)
- STATIC_ROOT configuration
- CSRF_TRUSTED_ORIGINS for Django 4.0+
- dj-database-url usage
- Gunicorn in requirements.txt
Flask:
- Gunicorn production server (not Flask development server)
- Procfile validation (gunicorn, 0.0.0.0, $PORT)
- Debug mode detection (app.run(debug=True) warnings)
FastAPI:
- Uvicorn production server configuration
- Procfile validation (uvicorn, --host 0.0.0.0, --port $PORT)
- Development mode warnings (uvicorn.run() detection)
- Workers recommendation for production
Testing
Try the included test projects:
railway-doctor scan test-projects/express-broken
railway-doctor scan test-projects/express-working --verbose
railway-doctor scan test-projects/nextjs-broken
railway-doctor scan test-projects/nextjs-working --verbose
railway-doctor scan test-projects/sveltekit-test --verbose
railway-doctor scan test-projects/django-broken
railway-doctor scan test-projects/django-working --verbose
railway-doctor scan test-projects/flask-broken
railway-doctor scan test-projects/flask-working --verbose
railway-doctor scan test-projects/fastapi-broken
railway-doctor scan test-projects/fastapi-working --verbose
railway-doctor scan test-projects/generic-nodejs
Project Structure
railway-doctor/
├── src/
│ ├── cli.ts # CLI entry point
│ ├── types.ts # TypeScript interfaces
│ ├── scanner/
│ │ ├── index.ts # Main scanner orchestrator
│ │ └── fileDetector.ts # Framework detection
│ ├── checks/
│ │ ├── portCheck.ts # PORT configuration check
│ │ ├── hostCheck.ts # Host binding check
│ │ └── startCommandCheck.ts # Start script validation
│ └── output/
│ └── formatter.ts # Terminal output formatting
├── test-projects/ # Example projects for testing
│ ├── express-broken/
│ └── express-working/
└── package.json
Development
Built with:
- Bun - Fast JavaScript runtime
- TypeScript - Type safety
- Commander - CLI framework
- Chalk - Terminal colors
- @babel/parser - JavaScript/TypeScript AST parsing
Roadmap
v0.1.0 (Complete)
v0.2.0 (Complete)
v0.3.0 (Complete - Latest)
Future Enhancements (v0.4.0+)
Contributing
Contributions welcome! This tool catches common deployment issues based on real Railway deployment failures. If you've encountered a deployment issue that could be detected automatically, please open an issue or PR.
License
MIT
Author
Built as a solution to prevent common Railway deployment failures and save developers time debugging configuration issues.
Note: This tool is a diagnostic utility and is not officially affiliated with Railway. It's a community tool built to help developers deploy successfully.