---
title: "Deploy AI Memory"
description: "One-click deploy: shared AI agent memory with MCP and authentication."
category: "AI/ML"
url: https://railway.com/deploy/ai-memory
---

# Deploy AI Memory

One-click deploy: shared AI agent memory with MCP and authentication.

**[Deploy AI Memory on Railway](https://railway.com/template/ai-memory)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/ai-memory/manifest.json

- **Creator:** RBR Digital
- **Category:** AI/ML
- **Total deploys:** 1

## Template content

### AI Memory https://github.com/akitaonrails/ai-memory/blob/main/docs/logo.png?raw=true

- **Image:** akitaonrails/ai-memory:latest
- **Start command:** `/bin/sh -ec ': "${AI_MEMORY_AUTH_TOKEN:?Set AI_MEMORY_AUTH_TOKEN}"; : "${AI_MEMORY_ALLOWED_HOSTS:?Set AI_MEMORY_ALLOWED_HOSTS}"; case "$AI_MEMORY_AUTH_TOKEN" in *[[:space:]]*) exit 1;; esac; test "$(id -u)" = 0; test -d /data; test ! -L /data; umask 077; find /data -xdev ! -type l ! -user ai-memory -exec chown -h ai-memory:ai-memory {} +; chmod 700 /data; export HOME=/data AI_MEMORY_DATA_DIR=/data; exec /usr/bin/setpriv --reuid=ai-memory --regid=ai-memory --init-groups --no-new-privs /usr/local/bin/ai-memory serve --transport http --bind "0.0.0.0:${PORT:-49374}" --enable-web'`
- **Health check:** /healthz
- **Public domain:** Yes

## Documentation

# Deploy and Host AI Memory on Railway

AI Memory is an open-source memory server by Fábio Akita that helps AI coding agents preserve context across sessions. It combines an MCP interface, lifecycle hooks, searchable project knowledge, and Git-backed Markdown history. Connect compatible agents to retain decisions, recover context, and hand off work across tools.

## About Hosting AI Memory

This template runs the official AI Memory Docker image with a persistent volume mounted at `/data`. It exposes HTTP MCP, a browser interface, and hook ingestion for compatible agents. Railway provides HTTPS networking; AI Memory handles browser login and API authentication. A custom start command prepares volume ownership, then runs the server as its unprivileged user. SQLite, configuration, credential state, and Markdown/Git history persist across restarts. Deploy one replica per data directory, configure backups, and connect compatible clients to `/mcp`. Install supported lifecycle hooks separately to capture session activity automatically. No external PostgreSQL or Redis service is required.

## Common Use Cases

- Preserve project decisions and context across AI coding sessions
- Share searchable knowledge between compatible coding agents
- Capture session activity and coordinate supported handoffs across tools

## Dependencies for AI Memory Hosting

- Official [AI Memory Docker image](https://hub.docker.com/r/akitaonrails/ai-memory)
- Persistent Railway volume mounted at `/data`
- Public HTTPS domain and authentication variables
- Compatible MCP clients, with lifecycle hooks for automatic session capture

Documentation: [AI Memory GitHub](https://github.com/akitaonrails/ai-memory), [Installation Guide](https://github.com/akitaonrails/ai-memory/blob/main/docs/install.md), [Authentication Guide](https://github.com/akitaonrails/ai-memory/blob/main/docs/users.md), and [Railway Documentation](https://docs.railway.com).

### Implementation Details

**Environment variables**

| Variable | Value |
|----------|-------|
| `PORT` | `49374` |
| `RAILWAY_RUN_UID` | `0` |
| `AI_MEMORY_AUTH_TOKEN` | `${{secret(64, "abcdef0123456789")}}` |
| `AI_MEMORY_ALLOWED_HOSTS` | `${{RAILWAY_PUBLIC_DOMAIN}},localhost,127.0.0.1,healthcheck.railway.app` |
| `AI_MEMORY_AUTH__TOKEN_PEPPER` | `${{secret(64, "abcdef0123456789")}}` |
| `AI_MEMORY_AUTH__ROOT_USERNAME` | `admin` |
| `AI_MEMORY_AUTH__SECURE_COOKIE` | `true` |
| `AI_MEMORY_AUTH__RECOVERY_TOKEN` | `${{secret(64, "abcdef0123456789")}}` |
| `AI_MEMORY_AUTH__INITIAL_ROOT_PASSWORD` | `${{secret(64, "abcdef0123456789")}}` |

**Startup permissions:** `RAILWAY_RUN_UID=0` must be paired with the template’s custom start command. Root prepares the volume; the command then drops privileges and runs AI Memory as UID 1000. Do not remove the privilege-dropping command while keeping this variable enabled.

**Storage:** Mount and preserve the entire `/data` directory. Keep `AI_MEMORY_AUTH__TOKEN_PEPPER` stable across restarts and redeployments; changing it invalidates existing API credentials.

**Networking:** Point the public HTTPS domain to internal port `49374`. Use `/web` for the browser interface, `/mcp` for MCP clients, `/hook` for lifecycle hook ingestion, and `/healthz` as the healthcheck path.

**First login:** Open `/web`, sign in as `admin` with the generated initial password, and complete the required password change. Remove `AI_MEMORY_AUTH__INITIAL_ROOT_PASSWORD` afterward. Store the optional recovery token securely.

**Agent access:** Create individual API credentials instead of sharing the administrative bearer token. Configure MCP registration and supported lifecycle hooks separately.

**Scaling and backups:** This SQLite-backed deployment requires a single replica per data directory. Scale vertically and configure volume backups; Git history alone does not preserve accounts, credentials, or all operational state.

## Why Deploy AI Memory on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying AI Memory on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

For this AI Memory template specifically, keep one replica and scale vertically because it uses SQLite and a persistent volume.

Template created and maintained by **Douglas Rubim**. AI Memory is developed by **Fábio Akita and its contributors**.

GitHub: https://github.com/douglasrubims

## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.
- [Hermes Agent | OpenClaw Alternative with Dashboard](https://railway.com/deploy/hermes-agent-or-openclaw-alternative-wit) — Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

Open this page in a browser: https://railway.com/deploy/ai-memory
