Overview
Railway provides a simple platform for deploying Node.js applications with built-in support for persistent storage, environment variables, and monitoring. This guide shows a complete production setup including:- Cursor persistence for resumable indexing
- Proper error handling and logging
- Rollback handlers for blockchain reorganizations
- File-based data storage
- Automated Railway deployment
While SST supports Railway through the Railway Terraform provider, this guide uses Railway’s native deployment methods which are simpler and better documented for Node.js applications.
Prerequisites
Before starting, ensure you have:- A Railway account
- Node.js 22+ installed
- Git for version control
- GitHub account (for deployment option 1)
Complete Example Pipe
Here’s a production-ready Pipe that indexes USDC transfers with cursor persistence:Dockerfile
Create a Dockerfile for Railway deployment:Dockerfile
Deployment Options
Choose your preferred deployment method:- GitHub Integration (Recommended)
- Railway CLI
Deploy automatically from your GitHub repository:
Create Railway project
- Log in to Railway Dashboard
- Click New Project
- Select Deploy from GitHub repo
- Choose your repository
- Railway will automatically detect the Dockerfile and deploy
Configure environment variables
In the Railway dashboard:
- Go to your service’s Variables tab
- Add environment variables:
Verification
Verify your deployment is working correctly:Check deployment status
In the Railway dashboard:
- Navigate to your project
- Check the Deployments tab
- Verify the latest deployment shows “Active”
- Click on the deployment to view build logs
View live logs
- Railway Dashboard
- Railway CLI
- Go to your service
- Click the Logs tab
- Watch for processing messages:
Verify cursor progression
Check that the cursor is advancing:You should see:
- Use Railway’s shell feature to access your container:
- View the cursor file:
Production Best Practices
Persistent Storage
Persistent Storage
Use Railway Volumes for cursor persistence:Update your code to store cursor in the mounted volume:
Error Handling
Error Handling
Implement robust error handling:
Monitoring
Monitoring
Set up health checks and alerts:
- Use Railway’s built-in monitoring
- Add a health check endpoint (optional):
- Configure Railway health check in Settings → Health Check
Environment Configuration
Environment Configuration
Use environment-specific settings:
Graceful Shutdown
Graceful Shutdown
Handle shutdown signals properly:
Troubleshooting
Common issues and solutions:| Issue | Solution |
|---|---|
| Cursor resets on restart | Add a persistent volume in Railway settings mounted to /app/data |
| Out of memory errors | Increase memory in Settings → Resources, or reduce batch size |
| Build fails | Check Dockerfile syntax and ensure all dependencies are in package.json |
| No data output | Verify PORTAL_URL is set correctly and check logs for errors |
| Slow indexing | Check network latency, consider caching, optimize batch size |
Next Steps
Data Persistence
Advanced patterns for cursor and state management
Stateful Indexing
Handle blockchain reorganizations with rollback handlers
Performance
Optimize your indexer for high-throughput chains
Event Decoding
Type-safe event decoding with generated ABIs

