Deploy Guide

Take Authorail from local development to a production environment.

Architecture Overview

Authorail runs as two separate servers, each with a distinct role:

ServerPurposeAudience
Admin ServerPolicy management, audit logs, dashboard APIHuman operators
Agent ServerGateway for spend requests, policy enforcementAI agents (MCP clients)

Separating the servers lets you apply different network rules, scaling, and access controls to each.

Admin Server

The admin server exposes the management API for creating policies, reviewing audit events, and configuring quotas.

uv run python -m authorail.admin_server

By default it listens on port 8000. Put it behind an authenticated reverse proxy (e.g. Caddy, nginx, or a cloud load balancer) so only authorized operators can reach it.

Agent Server (Gateway Mode)

The agent server handles incoming spend requests from AI agents. It evaluates each request against active policies and returns allow, deny, or approval-required decisions.

uv run python -m authorail.server

By default it listens on port 8001. This is the endpoint your MCP clients connect to in production.

Environment Variables

Configure both servers via environment variables or a .env file:

VariableRequiredDefaultDescription
DATABASE_URLYes—Database connection string (PostgreSQL recommended for production)
ADMIN_API_KEYYes—Secret key for admin API authentication
ORG_IDNodefaultOrganization identifier for multi-tenant deployments
LOG_LEVELNoinfoLogging verbosity: debug, info, warning, error
CORS_ORIGINSNo*Comma-separated list of allowed CORS origins
PORTNo8000 / 8001Override the default listening port

Production Database

For production, use PostgreSQL instead of SQLite:

DATABASE_URL=postgresql://user:password@host:5432/authorail

Run migrations after switching databases:

uv run alembic upgrade head

Deployment Options

Docker

docker build -t authorail .
docker run -d --env-file .env -p 8000:8000 authorail

Cloud Platforms

Authorail works with any platform that can run a Python process:

  • Railway / Render — connect your repo and set environment variables in the dashboard.
  • AWS ECS / GCP Cloud Run — containerize with the Dockerfile and deploy to your container orchestrator.
  • VPS — run behind a process manager like systemd or supervisord.

Troubleshooting

SymptomLikely CauseFix
Connection refused on port 8000Admin server not runningStart with uv run python -m authorail.admin_server
401 Unauthorized on admin APIWrong or missing API keyCheck ADMIN_API_KEY matches your request header
no such table errorsMigrations not appliedRun uv run alembic upgrade head
Agent requests timing outAgent server not reachableVerify PORT and network/firewall rules
Stale policy changesCaching in reverse proxyDisable caching for API routes or reduce TTL

Next Steps

  • Getting Started — initial setup and first workflow
  • Pricing — compare plans for your team size
  • Blog — learn about AI agent governance patterns