---
title: "Deploy claude-mem | Persistent Memory Server for Claude Code"
description: "claude-mem server: shared memory for Claude Code, Codex and agents"
category: "AI/ML"
url: https://railway.com/deploy/claude-mem
---

# Deploy claude-mem | Persistent Memory Server for Claude Code

claude-mem server: shared memory for Claude Code, Codex and agents

**[Deploy claude-mem | Persistent Memory Server for Claude Code on Railway](https://railway.com/template/claude-mem)**

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

- **Creator:** Two Workspaces
- **Category:** AI/ML

## Template content

### Redis https://devicons.railway.app/i/redis.svg

- **Image:** redis:8.10.2-alpine
- **Start command:** `/bin/sh -c "rm -rf /data/lost+found && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --appendonly yes --appendfsync everysec --maxmemory-policy noeviction"`

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** pgvector/pgvector:0.8.7-pg17-trixie

### claude-mem https://raw.githubusercontent.com/thedotmack/claude-mem/v15.7.0/plugin/ui/claude-mem-logo-stylized.png

- **Image:** ghcr.io/two-workspaces/claude-mem:c568a54
- **Health check:** /healthz
- **Public domain:** Yes

## Documentation

# Deploy and Host claude-mem on Railway

[![Deploy on Railway](https://railway.com/button.svg)](https://railway.com/new/template/claude-mem?referralCode=sLjDXb&utm_medium=integration&utm_source=button&utm_campaign=claude-mem)

[claude-mem](https://github.com/thedotmack/claude-mem) gives Claude Code (and Codex, OpenCode, Gemini CLI and other agents) a memory that lasts across sessions. It captures what your agent does, compresses it into short observations with Claude, and feeds the relevant ones back into later sessions. This template runs claude-mem's **server runtime**, so that memory lives in one place on Railway instead of on one laptop: every machine and teammate that holds the API key reads and writes the same memory, and any MCP client can search it.

## About Hosting claude-mem

Three services on Railway's private network:

- **claude-mem**: the server runtime from a pinned claude-mem release. It serves the `/v1` API and the `/v1/mcp` recall endpoint, and runs memory generation in the same process. The embedding model for search by meaning is baked into the image.
- **Postgres 17 with pgvector**, holding events, observations, sessions and API keys, on a volume.
- **Redis** for the BullMQ generation queue, with append-only persistence on a volume.

On first boot the server creates a team, a project and an API key with read and write access. The key is `CLAUDE_MEM_API_KEY`, generated by Railway when you deploy. Every request needs it, so the public URL is useless without it.

## Common Use Cases

- Keep one Claude Code memory across your laptop, desktop and cloud dev boxes
- Share project memory with teammates, so their agent knows what yours already learned
- Search past sessions from any MCP client: "when did we change the retry limit?"
- Give hosted agents (Hermes, OpenClaw, CI bots) a memory that survives redeploys

## Dependencies for claude-mem Hosting

- An Anthropic API key (`ANTHROPIC_API_KEY`) for memory generation. Gemini and OpenRouter work too.
- claude-mem installed on each machine whose sessions you want captured (`npx claude-mem install`).

### Deployment Dependencies

- [claude-mem on GitHub](https://github.com/thedotmack/claude-mem)
- [claude-mem docs](https://docs.claude-mem.ai)
- [Anthropic API keys](https://console.anthropic.com/settings/keys)

### Implementation Details

**Recall from any MCP client** (read-only). Copy `CLAUDE_MEM_API_KEY` from the claude-mem service's Variables tab, then:

```bash
claude mcp add --transport http claude-mem https://‹your-domain›/v1/mcp \
  --header "Authorization: Bearer ‹CLAUDE_MEM_API_KEY›"
```

**Capture from Claude Code.** Install claude-mem locally, then point its hooks at the server in `~/.claude-mem/settings.json`. The project id is printed in the claude-mem service's deploy logs (`[railway-setup] project id: ...`):

```json
{
  "CLAUDE_MEM_RUNTIME": "server",
  "CLAUDE_MEM_SERVER_URL": "https://‹your-domain›",
  "CLAUDE_MEM_SERVER_API_KEY": "‹CLAUDE_MEM_API_KEY›",
  "CLAUDE_MEM_SERVER_PROJECT_ID": "‹project id›"
}
```

**Generation provider:** `claude` by default, using `ANTHROPIC_API_KEY`. For Gemini set `CLAUDE_MEM_SERVER_PROVIDER=gemini` and `GEMINI_API_KEY`; for OpenRouter, `openrouter` and `OPENROUTER_API_KEY`. Without a key, events are still stored and nothing is generated until you add one.

**More keys:** `POST /v1/keys` with your key mints a read-only key for a teammate and returns a ready `claude mcp add` command.

Notes and limits:

- claude-mem's server runtime is labelled beta upstream; routes and settings can change between releases. The template pins a release and is updated deliberately.
- Generation calls cost provider tokens on every captured event. Set `CLAUDE_MEM_MONTHLY_TOKEN_CAP` on the claude-mem service to cap spend.
- `CLAUDE_MEM_API_KEY` only matters on first boot. To replace it, set a new value: the next boot adds it as another key. Revoke the old one in Postgres (`api_keys.revoked_at`).
- Back up the Postgres volume before upgrades; it holds all your memory.

## Why Deploy claude-mem 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 claude-mem 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.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Weaviate](https://railway.com/deploy/weaviate-1) — Vector database with hybrid search and an API key-protected API
- [Möbius v0.1 Personal AI OS](https://railway.com/deploy/mobius-v01-personal-ai-os) — Self-hosted AI agent that builds and runs apps for you, with memory.

Open this page in a browser: https://railway.com/deploy/claude-mem
