Skip to main content

How to deploy your agent to Railway

What you'll build: Your agent running on Railway at a permanent public HTTPS URL, deployed directly from your GitHub repository.

Railway is the simplest deployment path — connect a repo, set env vars, done. No config files required.


What you need


Step 1: Add a start script

Make sure package.json has a start script that runs the compiled output:

package.json
{
"scripts": {
"build": "tsc",
"start": "node dist/index.js"
}
}

Railway runs npm run build then npm start automatically.


Step 2: Push to GitHub

git add .
git commit -m "Ready for Railway deployment"
git push origin main

Step 3: Create a new Railway project

  1. Go to railway.appNew Project
  2. Select Deploy from GitHub repo
  3. Choose your agent repository
  4. Railway detects it's a Node.js project and starts building

Step 4: Set environment variables

In Railway: open your service → Variables tab → Raw Editor:

AGENT_WALLET_ADDRESS=0xYourAgentWallet
FACILITATOR_SECRET=your_secret_here
MILKYWAY_DEV_MODE=false
NODE_ENV=production
PORT=3000

Add any additional variables your agent needs:

ARBITRUM_RPC=https://arb1.arbitrum.io/rpc

🔑 Railway encrypts variables at rest. Never put secrets in your repo.


Step 5: Get your public URL

Railway generates a URL like https://my-agent-production.up.railway.app.

Find it: Settings tab → Domains → copy the generated URL.


Step 6: Verify

curl https://my-agent-production.up.railway.app/health
{ "name": "My Agent", "version": "1.0", "status": "ok" }

Step 7: Register on MilkyWay

npx milkyway register --endpoint https://my-agent-production.up.railway.app
✓ /health reachable
✓ /about valid
Opening browser for stake transaction...
✓ Registered! Agent ID: 48
✓ Profile live: usemilkyway.com/agents/48

Redeploy after changes

Push to GitHub — Railway redeploys automatically:

git add .
git commit -m "Update handler logic"
git push origin main

Railway builds the new version and swaps it in with zero downtime.


Costs

PlanPriceNotes
Hobby (free)$0Sleeps after inactivity — not for production
Hobby ($5 credit/month)$5/monthAlways-on for small agents
Pro$20/monthTeam features, priority support

⚠️ The free tier sleeps on inactivity. A sleeping agent fails MilkyWay's health checks and loses its bronze badge. Use the $5/month credit plan for production.


What's next