Railway Deployment
Deploy LibreChat on Railway with automatic builds, managed databases, and easy scaling.Quick Deploy
Deploy to Railway
Click to deploy LibreChat with pre-configured MongoDB and environment
What Gets Deployed
The Railway template includes:- LibreChat Application - Main web service
- MongoDB - Database (Railway’s MongoDB plugin)
- Meilisearch - Search engine (optional)
- Automatic SSL - HTTPS with custom domains
- Environment Variables - Pre-configured settings
Manual Deployment
If you prefer to deploy manually:Create Railway Account
- Go to railway.com
- Sign up with GitHub account
- Verify your email
Create New Project
- Click “New Project”
- Select “Deploy from GitHub repo”
- Connect your GitHub account
- Select
danny-avila/LibreChator your fork
Add MongoDB
- Click ”+ New” in your project
- Select “Database” > “Add MongoDB”
- Railway will automatically provision a MongoDB instance
- Note the connection string from the “Connect” tab
Configure Build Settings
Railway should auto-detect these, but verify:Build Command:Start Command:Dockerfile (Alternative):
Railway can also build from Dockerfile:
Configuration
Custom Domain
Add Domain in Railway
- Go to your LibreChat service
- Click “Settings” > “Domains”
- Click “Custom Domain”
- Enter your domain (e.g.,
chat.yourdomain.com)
Adding Meilisearch
Create Meilisearch Service
- Click ”+ New” > “Empty Service”
- Name it “Meilisearch”
- Go to “Settings” > “Deploy”
Volume Persistence
Railway provides ephemeral storage by default. For persistent storage:Add Volume
- Go to your service settings
- Click “Volumes”
- Click ”+ New Volume”
- Set mount path:
/app/uploads
Environment Variables Reference
Required Variables
| Variable | Description | Example |
|---|---|---|
MONGO_URI | MongoDB connection string | ${{MongoDB.MONGO_URL}} |
CREDS_KEY | Encryption key (hex 32) | 9e95d9894d... |
CREDS_IV | Encryption IV (hex 16) | ac028c86b... |
JWT_SECRET | JWT signing key | 16f8c0ef4... |
JWT_REFRESH_SECRET | Refresh token key | eaa5191f2... |
Optional Variables
| Variable | Description | Default |
|---|---|---|
OPENAI_API_KEY | OpenAI API key | user_provided |
ANTHROPIC_API_KEY | Anthropic API key | user_provided |
GOOGLE_KEY | Google API key | user_provided |
ALLOW_REGISTRATION | Allow new signups | true |
ALLOW_EMAIL_LOGIN | Email/password login | true |
SEARCH | Enable search | false |
DEBUG_LOGGING | Enable debug logs | false |
Railway-Specific Variables
Railway provides these automatically:Monitoring & Logs
View Logs
- Go to your service
- Click “Deployments”
- Select active deployment
- View real-time logs
Metrics
Railway provides:- CPU usage
- Memory usage
- Network traffic
- Deployment history
Health Checks
LibreChat exposes a health endpoint:Scaling
Vertical Scaling
- Go to service “Settings”
- Adjust resources:
- Starter: 512 MB RAM, 1 vCPU
- Developer: 8 GB RAM, 8 vCPU
- Team: 32 GB RAM, 32 vCPU
Horizontal Scaling
Cost Optimization
Free Tier
Railway offers:- $5 free credit/month
- Pay only for usage
- No credit card required to start
Estimated Costs
| Usage Level | Monthly Cost |
|---|---|
| Light (< 100 users) | $5-15 |
| Medium (100-1000 users) | $15-50 |
| Heavy (1000+ users) | $50+ |
Reduce Costs
- Optimize Memory: Adjust
NODE_MAX_OLD_SPACE_SIZE - Use Sleep Mode: Enable for development projects
- Optimize Queries: Add database indexes
- CDN for Assets: Use external CDN for images
Troubleshooting
Build Failures
Issue: Build timeout or out of memoryDatabase Connection Issues
Issue: Cannot connect to MongoDB- Check
MONGO_URIuses${{MongoDB.MONGO_URL}} - Verify MongoDB service is running
- Check MongoDB logs for errors
Domain Not Working
Issue: Custom domain shows error- Verify CNAME record is correct
- Wait for DNS propagation (up to 48 hours)
- Check SSL certificate is issued
- Update
DOMAIN_CLIENTandDOMAIN_SERVER
High Memory Usage
Issue: Service crashes with OOM errorsMigration from Other Platforms
From Docker
-
Export MongoDB data:
-
Import to Railway MongoDB:
- Deploy LibreChat on Railway
From Other Hosts
- Copy
.envvariables to Railway - Migrate database to Railway MongoDB
- Update domain settings
- Test thoroughly before DNS cutover
Best Practices
- Use strong, unique secrets for all keys
- Enable automatic deployments from GitHub
- Set up custom domain with SSL
- Configure volumes for persistent storage
- Monitor logs and metrics regularly
- Set up health check alerts
- Keep dependencies updated
- Use environment-specific variables
- Test deployments in staging first
- Document your configuration
Support
- Railway Docs: docs.railway.app
- Railway Discord: discord.gg/railway
- LibreChat Discord: discord.librechat.ai