Railway is the simplest option for deploying Maillayer. It handles databases, environment variables, and deployments in one place—no server management required.

Why Railway?

  • One-click MongoDB and Redis setup
  • Auto-deploys from GitHub
  • Built-in logging and monitoring
  • No Docker or server knowledge needed
  • Generous free tier to get started

Prerequisites

  • A GitHub account
  • A Railway account (sign up here — get $20 in credits)
  • Maillayer repository forked to your GitHub

Step 1: Create a New Project

  1. Log into Railway and click New Project
  2. Select Deploy from GitHub repo
  3. Choose your forked Maillayer repository
  4. Railway will automatically detect the Dockerfile

Step 2: Add MongoDB Database

  1. In your project, click NewDatabaseAdd MongoDB
  2. Railway will provision a MongoDB instance
  3. Copy the MONGO_URL from the MongoDB service's Variables tab

Step 3: Add Redis Database

  1. Click NewDatabaseAdd Redis
  2. Railway will provision a Redis instance
  3. Copy the REDIS_URL from the Redis service's Variables tab

Step 4: Configure Environment Variables

Click on your Maillayer service, go to Variables, and add:

NODE_ENV=production
BASE_URL=https://your-app.up.railway.app
NEXTAUTH_SECRET=your-secret-key-minimum-32-characters
TRACKING_SECRET=your-tracking-secret
MONGODB_URI=<paste MongoDB URL from Step 2>
REDIS_URL=<paste Redis URL from Step 3>

Railway automatically provides the database URLs as reference variables. You can use ${{MongoDB.MONGO_URL}} syntax to reference them directly.

Step 5: Deploy

  1. Railway auto-deploys when you push to your main branch
  2. Click Deploy to trigger a manual deployment
  3. Wait 3-5 minutes for the build to complete
  4. Click the generated URL to access your Maillayer instance

Step 6: Add Custom Domain (Optional)

  1. Go to SettingsDomains
  2. Click Generate Domain for a free *.up.railway.app subdomain
  3. Or click Custom Domain and add your own domain
  4. Update your BASE_URL environment variable to match

Monitoring & Logs

  • View real-time logs in the Deployments tab
  • Monitor resource usage in the Metrics tab
  • Railway restarts crashed services automatically

Estimated Costs

ResourceFree TierPaid
Compute$5 credit/month~$5-10/month
MongoDBIncluded~$5-7/month
RedisIncluded~$3-5/month

Total: Free to start, ~$13-22/month for production workloads.

Troubleshooting

Build fails with memory error

  • Railway's free tier has limited memory. Upgrade to a paid plan or reduce build concurrency.

Workers not starting

  • Check logs for connection errors. Ensure MONGODB_URI and REDIS_URL are correctly set.

Can't connect to database

  • Verify you're using the internal Railway URL, not the public one.