---
title: "Deploy MemMachine"
description: "Memory layer for AI agents: REST and MCP API with Postgres and Qdrant"
category: "AI/ML"
url: https://railway.com/deploy/memmachine
---

# Deploy MemMachine

Memory layer for AI agents: REST and MCP API with Postgres and Qdrant

**[Deploy MemMachine on Railway](https://railway.com/template/memmachine)**

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

- **Creator:** Agaz Self-Host
- **Category:** AI/ML

## Template content

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

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### Qdrant https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/qdrant.png

- **Source:** https://github.com/aalfath/memmachine-railway-template
- **Health check:** /readyz

### MemMachine https://raw.githubusercontent.com/MemMachine/MemMachine/v0.4.0/docs/images/hippo-medium.png

- **Source:** https://github.com/aalfath/memmachine-railway-template
- **Health check:** /api/v2/health
- **Public domain:** Yes

## Documentation

# Deploy and Host MemMachine on Railway

MemMachine is an open-source memory layer for AI agents. It stores conversation episodes and user profile facts and returns the relevant ones when an agent asks, so assistants remember people, preferences and past sessions. Agents use it through a REST API, an MCP server, or the Python and TypeScript clients.

## About Hosting MemMachine

This template runs MemMachine v0.4.0 as three services on Railway's private network. **MemMachine** serves the REST API and MCP endpoint on its public domain, behind a small Caddy gate that requires a generated API key, because MemMachine has no login of its own. **Qdrant** stores the vectors for long-term episodic memory. **Postgres** holds episodes, sessions, projects and profile memory; MemMachine migrates it on boot. MemMachine waits for both databases before it starts. Every app service builds from a public GitHub repo that pins the official images by version and digest, and Qdrant and Postgres keep their data on volumes.

## Common Use Cases

* Long-term memory for chatbots and agents that should remember users across sessions
* Shared memory for Claude, Cursor or other MCP clients through the `/mcp` endpoint
* User profile extraction (preferences, facts) for personalised assistants
* A self-hosted alternative to hosted memory APIs, with your own model provider

## Dependencies for MemMachine Hosting

* PostgreSQL (included, Railway Postgres with pgvector)
* Qdrant (included, private service)
* An OpenAI API key, or a key for any OpenAI-compatible provider

### Deployment Dependencies

* [MemMachine on GitHub](https://github.com/MemMachine/MemMachine) and [release v0.4.0](https://github.com/MemMachine/MemMachine/releases/tag/v0.4.0)
* [MemMachine docs](https://docs.memmachine.ai)
* [Template repo, start scripts and changelog](https://github.com/aalfath/memmachine-railway-template)

### Implementation Details

The only prompt is `OPENAI_API_KEY`. MemMachine checks the embedding model and the LLM at startup and stops with an AuthenticationError if the key doesn't work. For another OpenAI-compatible provider, set `OPENAI_BASE_URL`, `LLM_MODEL` and `EMBEDDING_MODEL` on the MemMachine service (and `EMBEDDING_DIMENSIONS` if the vectors aren't 1536 long) before you store memories.

After deploy, copy `MEMMACHINE_API_KEY` from the MemMachine service's Variables tab and send it as `Authorization: Bearer YOUR-KEY`:

```sh
curl -X POST https://YOUR-DOMAIN/api/v2/memories/search \
  -H "Authorization: Bearer YOUR-KEY" -H "content-type: application/json" \
  -d '{"org_id":"acme","project_id":"demo","query":"Where does Alice live?"}'
```

In Python, use `MemMachineClient(api_key=..., base_url="https://YOUR-DOMAIN")`. MCP clients connect to `https://YOUR-DOMAIN/mcp/` with the same header. `/api/v2/health` and the API docs at `/docs` are public; everything else needs the key.

Not included: Neo4j, which upstream uses only for the alternative `declarative` memory backend (this template runs the default `event` backend on Qdrant and Postgres), and upstream's local docs site.

Updates: the services build from the template repo's `main` branch. When we bump MemMachine or Qdrant there, Railway shows you an update notice and you choose when to apply it. Read the repo's CHANGELOG.md first.

## Why Deploy MemMachine 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 MemMachine 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 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/memmachine
