Deploy Mem0 Memory API + pgvector
Mem0 memory layer for AI agents: REST API, dashboard and pgvector Postgres
Postgres
Just deployed
Mem0 API
Just deployed
Mem0 Dashboard
Just deployed
Deploy and Host Mem0 on Railway
Mem0 is an open-source memory layer for AI agents and apps. It extracts durable facts from conversations, stores them as embeddings, and lets your agent recall them per user, agent, or session through a simple REST API. This template deploys the official self-hosted Mem0 server with its web dashboard and a pgvector Postgres database.
About Hosting Mem0
Hosting Mem0 means running the FastAPI REST server next to PostgreSQL with the pgvector extension, which holds both the memory embeddings and the app tables for users, API keys, request logs, and runtime settings. The dashboard is a separate Next.js service that talks to the API over its public HTTPS domain, and the API's CORS allow-list contains only the dashboard origin. Both app services are built directly from the upstream repository (server/ and server/dashboard/), because Mem0 does not publish a maintained prebuilt image for the current server. Authentication is on by default: the first visit to the dashboard runs a setup wizard that creates the admin account, and a generated ADMIN_API_KEY lets you call the API immediately.
Common Use Cases
- Agent memory: give chatbots and autonomous agents long-term memory across sessions
- Personalisation: remember user preferences, facts, and history per
user_id - Multi-agent state: scope memories by
agent_idandrun_id - Semantic recall:
POST /searchreturns the most relevant memories for a query - Auditing: the dashboard shows every API request, entity, and memory
Dependencies for Mem0 Hosting
- PostgreSQL with pgvector (included,
pgvector/pgvector:pg17) - OpenAI API key (required; the server initialises its OpenAI LLM and embedder at startup and will not boot without one)
- Anthropic or Google keys (optional; switch providers later in the dashboard Configuration page)
- No Neo4j and no Redis are needed for the REST server
Deployment Dependencies
Implementation Details
The API service installs the psycopg[binary] Postgres driver (upstream's Dockerfile currently omits it), runs alembic upgrade head so the app tables exist on first boot, then starts uvicorn on 0.0.0.0 so Railway's healthcheck can reach it. Memory history lives on a volume at /app/history. Both app services build from the upstream main branch, so a redeploy picks up upstream changes. Postgres holds the memories vector table and the app tables in one database.
PORT=8000
OPENAI_API_KEY=
JWT_SECRET=${{secret(64)}}
ADMIN_API_KEY=${{secret(32)}}
POSTGRES_HOST=${{Postgres.PGHOST}}
DASHBOARD_URL=https://${{Mem0 Dashboard.RAILWAY_PUBLIC_DOMAIN}}
NEXT_PUBLIC_API_URL=https://${{Mem0 API.RAILWAY_PUBLIC_DOMAIN}}
API_INTERNAL_URL=https://${{Mem0 API.RAILWAY_PUBLIC_DOMAIN}}
After deploy, open the dashboard URL and complete the setup wizard, then create a per-user API key under API Keys. Store a memory with POST /memories and the X-API-Key header, and read it back with GET /memories?user_id=.... Interactive API docs live at /docs on the API service.
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 get the API, dashboard, and pgvector database wired together with generated secrets, health checks, managed SSL, and private networking to the rest of your project.
Template Content
Postgres
pgvector/pgvector:pg17Mem0 API
mem0ai/mem0OPENAI_API_KEY
REQUIRED to boot. Mem0 builds its OpenAI LLM and embedder at startup and the openai client raises 'Missing credentials' without a key, so the server crash-loops if this is empty. Other providers (Anthropic, Gemini) can be switched on later from the dashboard Configuration page.
Mem0 Dashboard
mem0ai/mem0