Deploy Mem0

Mem0 2.2 self-hosted AI memory API and dashboard with Postgres pgvector.

Deploy Mem0

Just deployed

/app/history

/var/lib/postgresql/data

Deploy and Host Mem0 on Railway

Mem0 is an open-source memory layer for AI agents and assistants. It extracts facts from conversations with an LLM, stores them as vector embeddings, and returns the relevant memories for each user, agent or session when you search. Apps use it through its REST API or the official Python and TypeScript SDKs.

About Hosting Mem0

This template deploys the Mem0 v2.2.0 self-hosted server, its web dashboard and a Railway Postgres database. Memories are stored with pgvector, which Railway's Postgres already includes. Users and API keys live in a second database created on first start. You must provide an OpenAI API key when deploying; LLM and embedding calls are billed by OpenAI. The first account registered in the dashboard becomes admin, and registration then closes, so register right after deploying. The API also accepts a generated admin API key. Telemetry is off. The memory history database is kept on a small volume.

Common Use Cases

  • Giving chatbots and AI agents long-term, per-user memory across sessions
  • Personalizing assistants with user preferences and facts learned from conversations
  • A self-hosted alternative to the Mem0 cloud platform that keeps memories in your own database

Dependencies for Mem0 Hosting

  • Mem0 v2.2.0 server and dashboard built from aalfath/mem0-railway-template (upstream release tarball, checksum-pinned; mem0ai==2.2.0)
  • Railway Postgres (ghcr.io/railwayapp-templates/postgres-ssl:18) with pgvector
  • An OpenAI API key (default models gpt-5-mini and text-embedding-3-small)

Deployment Dependencies

Implementation Details

ServiceSourceNetworkingStorage
mem0repo, Dockerfilepublic API on 8000; private IPv4/IPv6volume at /app/history
dashboardrepo, dashboard/Dockerfilepublic domain on 3000none
PostgresRailway Postgres 18 (pgvector)private onlyvolume

Add and search memories:

curl -X POST "$MEM0_API_URL/memories" -H "X-API-Key: $ADMIN_API_KEY" -H "Content-Type: application/json" \
  -d '{"messages": [{"role": "user", "content": "I prefer dark roast coffee"}], "user_id": "alice"}'
curl -X POST "$MEM0_API_URL/search" -H "X-API-Key: $ADMIN_API_KEY" -H "Content-Type: application/json" \
  -d '{"query": "What coffee does Alice like?", "user_id": "alice"}'

From another Railway service, use ${{mem0.MEM0_PRIVATE_URL}}. Create per-user API keys in the dashboard instead of sharing the admin key. Interactive API docs are at /docs on the API domain.

VariableServiceDefaultPurpose
OPENAI_API_KEYmem0none (required)LLM and embeddings
ADMIN_API_KEYmem0generated secretAdmin access via X-API-Key
JWT_SECRETmem0generated secretSigns dashboard login tokens
MEM0_TELEMETRYmem0falseUpstream anonymous telemetry
RAILWAY_DOCKERFILE_PATHdashboarddashboard/DockerfileBuilds the dashboard image

Notes:

  • To use Anthropic or Gemini instead, add ANTHROPIC_API_KEY or GOOGLE_API_KEY and change the provider from the dashboard or POST /configure. OpenAI-compatible endpoints work through OPENAI_BASE_URL.
  • The API only accepts browser requests from the dashboard origin set in DASHBOARD_URL (CORS); keep the service names mem0 and dashboard.
  • Upstream fixes applied in the image: libpq5 installed (needed by psycopg), mem0ai pinned, and uvicorn --reload removed.
  • Back up Postgres; it holds all memories, users and API keys.

This is a community-maintained deployment package and does not imply affiliation with or endorsement by Mem0.

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.


Template Content

More templates in this category

View Template
Chat Chat
Chat Chat, your own unified chat and search to AI platform.

okisdev
116
View Template
stella
Self-host stella with web, API, Postgres, Redis, and object storage.

Jan Kubica
7
View Template
Hermes Agent | OpenClaw Alternative with Dashboard
Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

codestorm
79