Railway Deployment Guide
March 1, 2026 · View on GitHub
Complete guide for deploying GXQ Studio Advanced Solana DeFi Platform to Railway with automated CI/CD workflows.
Table of Contents
- Quick Start
- Prerequisites
- Required Secrets
- Automated Deployment
- Manual Deployment
- Environment Variables
- Health Checks
- Troubleshooting
- Rollback Procedures
- Cost Optimization
Quick Start
Option 1: Automated Setup (Recommended)
Run the interactive setup script:
bash scripts/setup-railway.sh
This script will:
- Install Railway CLI (if not already installed)
- Authenticate with Railway
- Link to the pre-configured project
- Configure environment variables
- Deploy the application
- Run health checks
Option 2: One-Click Deploy
Deploy directly from GitHub using the automated workflow:
- Go to Actions → Deploy to Railway
- Click Run workflow
- The deployment will automatically:
- Validate secrets
- Build the project
- Deploy to Railway
- Run health checks
- Create deployment record
Prerequisites
1. Railway Account
- Sign up at railway.app
- Create or access project ID:
2077acd9-f81f-47ba-b8c7-8bf6905f45fc
2. Railway CLI (for manual deployment)
# macOS/Linux
curl -fsSL https://railway.app/install.sh | sh
# Windows (PowerShell)
iwr https://railway.app/install.ps1 | iex
3. Node.js 20
node --version # Should be v20.x.x
4. Solana Wallet
- Private key in base58 format
- Recommended: Funded with at least 0.5 SOL for operations
5. RPC Provider
Recommended providers (in order of preference):
- QuickNode - Best reliability and features
- Helius - Excellent for DeFi
- Triton One - High-performance RPC
- Alchemy - Good alternative
⚠️ Do NOT use free public RPCs in production - they have rate limits and poor reliability.
Required Secrets
Configure these secrets in your GitHub repository settings (Settings → Secrets and variables → Actions):
Core Secrets
| Secret Name | Description | Example | Required |
|---|---|---|---|
RAILWAY_TOKEN | Railway API authentication token | ***** | ✅ Yes |
RAILWAY_PROJECT_ID | Railway project ID | 2077acd9-f81f-47ba-b8c7-8bf6905f45fc | ✅ Yes |
SOLANA_RPC_URL | Solana RPC endpoint URL | https://your-node.quiknode.pro/abc123/ | ✅ Yes |
WALLET_PRIVATE_KEY | Wallet private key (base58) | 5J7...xyz | ✅ Yes |
ADMIN_USERNAME | Admin panel username | admin | ✅ Yes |
ADMIN_PASSWORD | Admin panel password | strong_password_123 | ✅ Yes |
JWT_SECRET | JWT authentication secret | random_secret_key_here | ✅ Yes |
How to Get Railway Token
- Go to railway.app/account/tokens
- Click Create Token
- Name it (e.g., "GitHub Actions")
- Copy the token
- Add it as
RAILWAY_TOKENsecret in GitHub
How to Get Project ID
The project ID is pre-configured: 2077acd9-f81f-47ba-b8c7-8bf6905f45fc
Alternatively, you can find it:
- Open your Railway project
- Go to Settings
- Copy the Project ID
Automated Deployment
Production Deployment
Automatic deployment to production occurs:
- On every push to
mainbranch - Manual trigger via GitHub Actions
Workflow: .github/workflows/deploy-railway.yml
Features:
- ✅ Secret validation
- ✅ Dependency caching
- ✅ Build verification
- ✅ Automated deployment
- ✅ Health check validation
- ✅ Auto-rollback on failure
- ✅ Issue creation on failure
Preview Deployment (PR)
Automatic preview deployment on:
- Pull request opened
- Pull request synchronized (new commits)
- Pull request reopened
Workflow: .github/workflows/deploy-railway-preview.yml
Features:
- ✅ Ephemeral preview environment per PR
- ✅ Automatic PR comments with preview URL
- ✅ Health check validation
- ✅ Auto-cleanup when PR is closed
- ✅ Skip deployment with
skip-deploymentlabel
Secret Synchronization
Manually sync secrets from GitHub to Railway:
- Go to Actions → Sync Railway Secrets
- Click Run workflow
- Select environment:
production- Production environment onlypreview- Preview environment onlyall- Both environments
- Enable dry_run to preview changes without applying
Workflow: .github/workflows/sync-railway-secrets.yml
Manual Deployment
Using Railway CLI
1. Install and Login
# Install Railway CLI
curl -fsSL https://railway.app/install.sh | sh
# Login to Railway
railway login
2. Link to Project
# Link to pre-configured project
railway link 2077acd9-f81f-47ba-b8c7-8bf6905f45fc
# Verify link
railway status
3. Set Environment Variables
# From .env file
railway variables --set $(cat .env | xargs)
# Or individually
railway variables --set SOLANA_RPC_URL="your-rpc-url"
railway variables --set WALLET_PRIVATE_KEY="your-private-key"
railway variables --set ADMIN_USERNAME="admin"
railway variables --set ADMIN_PASSWORD="your-password"
railway variables --set JWT_SECRET="your-jwt-secret"
4. Deploy
# Deploy and follow logs
railway up
# Deploy in background
railway up --detach
# Deploy specific service
railway up --service backend
5. Verify Deployment
# Get deployment URL
railway domain
# View logs
railway logs
# Check status
railway status
Environment Variables
Required Variables
These must be configured for the application to work:
# Solana Configuration
SOLANA_RPC_URL=https://your-node.quiknode.pro/abc123/
# Wallet Configuration
WALLET_PRIVATE_KEY=5J7...xyz # base58 format
# Admin Panel
ADMIN_USERNAME=admin
ADMIN_PASSWORD=strong_password_123
# Authentication
JWT_SECRET=random_secret_key_here
Optional Variables
These have sensible defaults but can be customized:
# Environment
NODE_ENV=production # production, preview, development
LOG_LEVEL=info # debug, info, warn, error
# Trading Parameters
MINIMUM_PROFIT_SOL=0.01 # Minimum profit threshold (0.01 = 0.01 SOL)
MAX_SLIPPAGE=0.01 # Maximum slippage (0.01 = 1%)
# Dev Fee Configuration
DEV_FEE_ENABLED=true # Enable dev fee (true/false)
DEV_FEE_PERCENTAGE=0.10 # Dev fee percentage (0.10 = 10%)
# Performance
MAX_RETRIES=3 # Maximum retry attempts
TIMEOUT=30000 # Request timeout in milliseconds
# Railway Configuration
PORT=3000 # Application port (auto-set by Railway)
Environment-Specific Defaults
Production:
NODE_ENV=productionLOG_LEVEL=infoMINIMUM_PROFIT_SOL=0.01MAX_SLIPPAGE=0.01DEV_FEE_ENABLED=true
Preview:
NODE_ENV=previewLOG_LEVEL=debugMINIMUM_PROFIT_SOL=0.05(more conservative)MAX_SLIPPAGE=0.005(tighter slippage)DEV_FEE_ENABLED=false
Health Checks
Health Check Endpoint
Path: /api/health
Returns:
{
"status": "healthy",
"uptime": 3600,
"memory": {
"heapUsed": 150,
"heapTotal": 256,
"rss": 300
},
"bot": {
"running": true,
"paused": false,
"scanCount": 120,
"opportunitiesFound": 5,
"tradesExecuted": 2,
"totalProfit": 0.05,
"lastScanTime": 1703001234567,
"lastTradeTime": 1703001230000
},
"timestamp": 1703001234567
}
Status Codes:
200- Healthy (all systems operational)503- Unhealthy (service degraded or stopped)
Railway Health Check Configuration
Configured in railway.json:
{
"healthcheckPath": "/api/health",
"healthcheckTimeout": 30,
"healthcheckInterval": 60,
"healthcheckMaxRetries": 5
}
Behavior:
- Railway checks
/api/healthevery 60 seconds - Wait up to 30 seconds for response
- Retry up to 5 times on failure
- Auto-restart if health checks consistently fail
Manual Health Check
# Get deployment URL
DEPLOY_URL=$(railway domain)
# Check health
curl "$DEPLOY_URL/api/health"
# Check metrics
curl "$DEPLOY_URL/api/metrics"
Troubleshooting
Common Issues
1. Deployment Fails with "Missing Secrets"
Problem: Required secrets are not configured.
Solution:
- Go to repository Settings → Secrets and variables → Actions
- Add all required secrets (see Required Secrets)
- Re-run the workflow
2. Health Check Fails
Problem: /api/health returns 503 or times out.
Possible Causes:
- RPC connection failed
- Wallet private key invalid
- Insufficient SOL balance
- Application crashed
Solution:
# Check logs
railway logs
# Verify environment variables
railway variables
# Test RPC connection
curl -X POST $SOLANA_RPC_URL \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"getHealth"}'
# Check wallet balance
# (see logs for wallet address)
3. Build Fails
Problem: npm run build fails during deployment.
Solution:
- Check build logs:
railway logs - Verify
package.jsonscripts are correct - Ensure all dependencies are in
package.json - Test locally:
npm ci && npm run build
4. Application Crashes on Start
Problem: Application starts but immediately crashes.
Solution:
# View crash logs
railway logs --tail 100
# Common issues:
# - Missing environment variables
# - Invalid RPC URL
# - Invalid private key format
# - Port binding issues (Railway sets PORT automatically)
5. RPC Rate Limiting
Problem: "429 Too Many Requests" errors in logs.
Solution:
- Upgrade to paid RPC provider
- Increase polling intervals in
.env:SCAN_INTERVAL=10000 # 10 seconds instead of 5 - Use QuickNode, Helius, or Triton for production
6. Low Wallet Balance
Problem: "Insufficient balance" errors.
Solution:
- Check balance: See health endpoint or logs
- Fund wallet with at least 0.5 SOL
- Application requires SOL for:
- Transaction fees
- Flash loan deposits
- DEX swaps
Rollback Procedures
Automatic Rollback
The deployment workflow automatically rolls back on failure:
- Health check fails
- Build fails
- Deployment fails
No manual intervention needed - previous version restored automatically.
Manual Rollback
Using Railway Dashboard
- Go to Railway Dashboard
- Open your project
- Go to Deployments
- Find the previous successful deployment
- Click Redeploy
Using Railway CLI
# List recent deployments
railway status
# Rollback to previous deployment
railway rollback
# Rollback to specific deployment ID
railway rollback <deployment-id>
Emergency Rollback
If the application is completely broken:
# Stop current deployment
railway down
# Deploy from a specific commit
git checkout <working-commit-sha>
railway up
Cost Optimization
Railway Pricing
Railway uses usage-based pricing:
- Hobby Plan: $5/month for resources
- Pro Plan: Pay-as-you-go based on usage
Key Metrics:
- CPU usage
- RAM usage
- Network egress
- Build minutes
Optimization Tips
1. Use Sleep Mode
For non-critical environments:
{
"deploy": {
"sleepApplication": true
}
}
Application sleeps after 1 hour of inactivity, wakes on request.
2. Optimize Polling Intervals
# Production: Balance between responsiveness and cost
SCAN_INTERVAL=5000 # 5 seconds
# Development: Less frequent
SCAN_INTERVAL=30000 # 30 seconds
3. Use Preview Environments Sparingly
Preview deployments cost money:
- Add
skip-deploymentlabel to PRs that don't need preview - Clean up old preview deployments
- Limit preview duration
4. Monitor Resource Usage
# Check resource usage
railway status
# View metrics
curl "$DEPLOY_URL/api/metrics"
5. Optimize Build Times
Railway charges for build minutes:
- Use dependency caching (already configured)
- Keep dependencies minimal
- Use
.dockerignoreto exclude unnecessary files
6. Use Spot Instances (Advanced)
For non-critical workloads, consider spot instances (if available).
Cost Estimates
Typical Usage (Hobby Plan):
- Backend application: ~$3-5/month
- Preview environments: ~$1-2/month per active PR
- Total: ~$5-10/month
Production Usage (Pro Plan):
- High-traffic application: ~$20-50/month
- Multiple environments: +$5-10/month per environment
- Total: ~$30-70/month
Tips to Stay Within Hobby Plan:
- Run only production environment
- Disable preview deployments
- Use sleep mode for development
- Monitor usage regularly
Additional Resources
Documentation
Related Guides
Support
- GitHub Issues: github.com/SMSDAO/TradeOS/issues
- Railway Support: help.railway.app
Summary Checklist
Before deploying to Railway, ensure:
- Railway account created
- Railway CLI installed (for manual deployment)
- All required secrets configured in GitHub
- RPC provider selected (QuickNode/Helius/Triton recommended)
- Wallet funded with at least 0.5 SOL
- Environment variables reviewed and customized
- Health check endpoint tested locally
- Build succeeds locally:
npm run build - Tests pass:
npm test
Ready to deploy? Run:
# Automated setup
bash scripts/setup-railway.sh
# Or manual deployment
railway up
Need help? See Troubleshooting or open an issue on GitHub.