---
title: "Deploy Mem0"
description: "Memory layer for AI agents: Mem0 REST API, dashboard and pgvector"
category: "AI/ML"
url: https://railway.com/deploy/mem0-server
---

# Deploy Mem0

Memory layer for AI agents: Mem0 REST API, dashboard and pgvector

**[Deploy Mem0 on Railway](https://railway.com/template/mem0-server)**

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

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

## Template content

### Dashboard https://raw.githubusercontent.com/two-workspaces/mem0/main/icon.svg

- **Image:** ghcr.io/two-workspaces/mem0-dashboard:55201f7
- **Health check:** /api/health
- **Public domain:** Yes

### Mem0 https://raw.githubusercontent.com/two-workspaces/mem0/main/icon.svg

- **Image:** ghcr.io/two-workspaces/mem0:55201f7
- **Health check:** /auth/setup-status
- **Public domain:** Yes

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

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

## Documentation

# Deploy and Host Mem0 on Railway

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

Mem0 is the open-source memory layer for AI agents and assistants. Your app sends it the messages of a conversation; Mem0 uses a language model to pull out the facts worth keeping ("is vegetarian", "prefers short answers", "works on the billing service"), stores them per user, agent or run, updates or drops old ones when new information contradicts them, and gives back the relevant memories for the next prompt through a vector search. It is licensed Apache-2.0. This template runs Mem0 2.2.1's self-hosted server on Railway: the REST API, the dashboard and Postgres with pgvector, with logins and API keys required from the first boot.

This is a community template, not made or supported by Mem0.

## About Hosting Mem0

Before deploying, paste a model key into `OPENAI_API_KEY` on the **Mem0** service. An OpenAI key works as is (Mem0 uses `gpt-5-mini` and `text-embedding-3-small`). For OpenRouter, paste an OpenRouter key there and set `OPENAI_BASE_URL=https://openrouter.ai/api/v1`; the models then default to `openai/gpt-5-mini` and `openai/text-embedding-3-small`. `MEM0_DEFAULT_LLM_MODEL` and `MEM0_DEFAULT_EMBEDDER_MODEL` pick others.

Deploy and wait for the green checks. Then:

- **Dashboard:** open the **Dashboard** service's domain and sign in with `ADMIN_EMAIL` and `ADMIN_PASSWORD` from the **Mem0** service's variables (the password is generated). There you browse and delete memories, see every user and agent that has memories, watch the request log, change the models, and create API keys.
- **API:** the **Mem0** service's domain. Send `X-API-Key: ‹key›` with each request: the generated `ADMIN_API_KEY` from the Mem0 service's variables, or a per-user key from the dashboard. Interactive docs are at `/docs`.

```bash
curl -X POST https://‹your-mem0-domain›/memories \
  -H "X-API-Key: ‹key›" -H "Content-Type: application/json" \
  -d '{"messages":[{"role":"user","content":"I am vegetarian and allergic to peanuts."}],"user_id":"alice"}'

curl -X POST https://‹your-mem0-domain›/search \
  -H "X-API-Key: ‹key›" -H "Content-Type: application/json" \
  -d '{"query":"what can alice eat?","filters":{"user_id":"alice"}}'
```

**Why the admin is created for you:** upstream's server lets whoever first opens the setup page (or calls `/auth/register`) become the admin. This template creates the admin from `ADMIN_EMAIL` and `ADMIN_PASSWORD` before the API opens, so registration is closed from the start. Change the password later in the dashboard's Settings. Lost it? Set `RESET_ADMIN_PASSWORD=true` on the Mem0 service, redeploy (the password goes back to `ADMIN_PASSWORD`), then delete the variable.

**Model costs:** every `POST /memories` makes one or two model calls (extracting facts, then deciding what to add, update or delete) plus embeddings; every search makes one embedding call. The defaults are small, cheap models; watch your provider's usage page in the first days.

**Your data:** memories (vectors) and the users, API keys and settings live in the Postgres service on its volume. The Mem0 service's own volume keeps the memory change history and the recent messages Mem0 reads when extracting new facts. Redeploys keep both.

**Telemetry:** upstream sends anonymous usage events by default. This template sets `MEM0_TELEMETRY=false`; set it to `true` to send them.

## Common Use Cases

- Long-term memory for a chatbot, support assistant or coding agent, kept on your own infrastructure
- Remembering each user's preferences and facts across sessions without resending whole transcripts
- Shared or per-agent memory in multi-agent setups (scope memories by `user_id`, `agent_id` or `run_id`)
- A memory backend for the Mem0 Python and TypeScript SDKs, LangChain, LangGraph, CrewAI and other frameworks that speak Mem0's REST API
- Inspecting and cleaning what an assistant has learned about a user from a dashboard

## Dependencies for Mem0 Hosting

- Postgres with pgvector (included)
- An API key for OpenAI, OpenRouter or another OpenAI-compatible provider that serves both chat and embeddings

### Deployment Dependencies

- [Mem0 on GitHub](https://github.com/mem0ai/mem0)
- [Mem0 open-source documentation](https://docs.mem0.ai/open-source/overview)
- [Template source](https://github.com/two-workspaces/mem0)

### Implementation Details

- **Services:** Mem0 (the FastAPI server, on a Railway domain, with a small volume), Dashboard (Next.js, on its own domain) and Postgres 17 with pgvector on Railway's private network. Upstream's optional graph memory (Neo4j) is left out.
- **Images:** Mem0's own server image stopped updating in September 2025, so this template builds the 2.2.1 release itself on GitHub Actions: upstream's `server/` code unmodified, the `mem0ai` library pinned to the same version, and the dashboard built as upstream's Dockerfile does. A deploy pulls finished images; updates come as tested version bumps.
- **Database:** the first boot creates the `mem0_app` database (users, keys, settings) next to the memory database and runs upstream's migrations on every start.
- **Never crash-looping on a variable:** with no model key, a key the provider rejects, a too-short `JWT_SECRET` or `ADMIN_PASSWORD`, an invalid `ADMIN_EMAIL` or a database that never answers, the API serves a message saying what to fix instead of restarting over and over. The deploy logs say the same.
- **Other providers:** Mem0's image also bundles Anthropic and Gemini. Switch to them on the dashboard's Configuration page (or `POST /configure`); embeddings then need OpenAI-compatible or Gemini.
- **Memory:** measured on Railway with every service capped at 0.5 GB and again at 1 GB, under 20 memory adds and 60 searches: the API about 230 MB, the dashboard 50–150 MB and Postgres about 40–90 MB (Railway's figure, which includes file cache). Each fits a 0.5 GB service; no service was killed at either cap.

## Why Deploy Mem0 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 Mem0 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/mem0-server
