Railway

Deploy ChromaDB

Vector database that stores documents and finds similar ones

Deploy ChromaDB

Just deployed

Just deployed

/data

Deploy and Host ChromaDB on Railway

ChromaDB is an open-source embeddings database — the storage layer retrieval-augmented generation, semantic search and agent memory are built on. You hand it documents with their vectors, and it returns the nearest matches to a query vector in milliseconds, with metadata filters applied in the same call. Teams use it for product docs behind a support bot, or the memory an agent reads before it answers.

This template runs ChromaDB as a client-server deployment rather than an embedded library. The chroma service runs the official chromadb/chroma image with a 5 GB volume at /data, holding its SQLite metadata store and HNSW index files, and has no public domain. In front sits gateway, a Caddy proxy from gridalpha/chromadb-railway, which owns the public URL and checks credentials before anything reaches the database. That split matters: open-source Chroma ships no authentication, and its own guide says the basic stack "doesn't support any kind of authentication" and to put it behind an authenticating proxy. Self-host ChromaDB this way and it is reachable only through a credential you control.

Chroma server behind a Caddy gateway on Railway

Getting Started with ChromaDB on Railway

Set CHROMA_PASSWORD when you deploy — it is the one value the template needs, and the gateway refuses to start without it, so the database is never published without a lock on the door. A CHROMA_TOKEN is generated for you and is what your application code should send. Once the deploy is green, open the public URL with /docs on the end and sign in as chroma: you get a Swagger explorer for the v2 API, generated by the running server, where you can create a collection, add records and query it without writing code. /api/v2/healthcheck confirms the storage engine has opened the volume.

From your own code, point the Chroma client at the gateway host on port 443 with the bearer token as a header. Create a collection, add documents, then query — if the ids come back ranked by distance, the deployment works end to end. Everything lands on the volume, so redeploys keep your collections.

ChromaDB API explorer listing collection and record endpoints

List collections returning the support handbook collection

Vector query returning the three nearest handbook documents

About Hosting ChromaDB

Chroma is an Apache-2.0 embeddings database from chroma-core/chroma, rewritten in Rust for the 1.x line. A single-node server keeps collection metadata in SQLite and each collection's vectors in an HNSW index, held in memory while in use and persisted to disk. Self-host it when the embeddings come from data you would rather not send to a managed service, when you want a fixed monthly cost instead of per-gigabyte charges, or when the database should sit on the app's private network.

  • Collections with per-record documents, metadata and optional URIs
  • Vector search with metadata filters and full-text conditions in one query
  • Cosine, squared L2 and inner-product spaces, with tunable HNSW parameters
  • Python, TypeScript and Rust clients, plus LangChain and LlamaIndex integrations
  • A generated OpenAPI schema and Swagger UI served by the database itself

chroma is the database and stays private; its volume is the only durable state. gateway is a stock Caddy build whose entrypoint hashes your password at boot and installs two routes — an exact bearer-token match for API clients, checked first so SDKs never meet an authentication challenge, and basic auth for everything else, which lets a browser use the API explorer.

Why Deploy ChromaDB on Railway

Railway removes the parts of running a vector database that have nothing to do with vectors.

  • Persistent volume attached and mounted at the data path already
  • Private networking between gateway and database, no port exposed
  • A public HTTPS URL with a managed certificate
  • Health checks on both services, with automatic restarts
  • Vertical scaling by changing a memory limit, the knob that matters

Common Use Cases for Self-Hosted ChromaDB

  • Retrieval-augmented generation — chunk your docs, embed them, and retrieve the passages a language model should read before answering.
  • Agent memory — a durable store of past interactions that survives restarts, queried by similarity rather than by key.
  • Semantic search in a product — search a knowledge base, ticket archive or code corpus by meaning, filtered by tenant or date.
  • Deduplication — find near-duplicate records by nearest neighbour.

Dependencies for ChromaDB on Railway

  • chromachromadb/chroma:1.5.9, the official image. Listens on 8000, stores everything under /data on a 5 GB volume, private to the project.
  • gatewaygridalpha/chromadb-railway on caddy:2-alpine. Holds the public domain; the only service the internet reaches.

No external database, cache or object store is needed.

Environment Variables Reference

VariableServicePurpose
CHROMA_PASSWORDgatewayBasic-auth password. Required; hashed at boot.
CHROMA_USERNAMEgatewayBasic-auth username, defaults to chroma.
CHROMA_TOKENgatewayBearer token for clients. Needs 24+ characters.
CHROMA_PERSIST_PATHchromaData directory; must match the volume mount.
CHROMA_ALLOW_RESETchromaWhether /api/v2/reset may wipe collections.

Any key in the server's single_node_full.yaml reference config is settable as a CHROMA_-prefixed variable, double underscore for nesting: CHROMA_OPEN_TELEMETRY__ENDPOINT maps to open_telemetry.endpoint.

Deployment Dependencies

Hardware Requirements for Self-Hosting ChromaDB

HNSW holds the whole index in memory, so RAM caps collection size. Chroma's benchmarks give a rule for 1024-dimensional embeddings: roughly 245,000 vectors per gigabyte, plus 1 GB overhead. Latency stays near 5 ms past a million records — memory, not CPU, runs out first.

MinimumRecommended
CPU1 vCPU2–4 vCPU
RAM2 GB8 GB (~1.7M vectors)
Storage5 GB volume10 GB+ for large corpora
RuntimeDockerDocker

Below 2 GB is not recommended upstream. Raise memory on chroma first.

Self-Hosting ChromaDB with Docker

The published image needs no build step. This runs a server with its data on a host directory:

docker run -d --name chroma -p 8000:8000 -v ./chroma-data:/data chromadb/chroma:1.5.9

The following is the Python client talking to a deployment of this template:

import chromadb

client = chromadb.HttpClient(
    host="your-app.up.railway.app",
    port=443,
    ssl=True,
    headers={"Authorization": "Bearer YOUR_CHROMA_TOKEN"},
)

c = client.get_or_create_collection("handbook")
c.add(ids=["kb-001"], documents=["Reset a forgotten password from settings."])

print(c.query(query_texts=["how do I reset my password"], n_results=3))

The server does not embed text for you. The Python client embeds locally when you pass documents; other clients send vectors you produce.

How Much Does ChromaDB Cost to Self-Host?

Chroma is free and open source under Apache-2.0, with no paid tier or feature gate. Chroma Cloud, the managed service from the same team, bills by usage — roughly $2.50 per GiB written and $0.33 per GiB-month stored, plus query and egress. Self-hosting replaces that with plain infrastructure cost: one small container, one Caddy container and a volume. For a steady corpus that is usually cheaper, and it is predictable.

FAQ

What is ChromaDB? An open-source embeddings database that stores documents alongside their vectors and retrieves them by semantic similarity — the retrieval layer under RAG, semantic search and agent memory.

What does this Railway template deploy? Two services: the official chromadb/chroma server on a persistent volume, kept private, and a Caddy gateway that owns the public URL and authenticates every request.

Why does this template include a separate gateway service? Open-source Chroma has no authentication, so publishing it directly would expose every collection to anyone with the URL. The gateway adds bearer-token and basic-auth credentials in front, as upstream's documentation recommends.

How do I connect to self-hosted ChromaDB from Python? Use chromadb.HttpClient with host set to your Railway domain, port=443, ssl=True, and an Authorization: Bearer header. The rest of the API matches the embedded client.

Does self-hosted ChromaDB generate embeddings for me? No. The server stores and searches vectors, it does not run an embedding model. The Python client embeds text locally; other clients expect vectors you supply.

Why does ChromaDB need a volume on Railway? Collections live in SQLite and HNSW index files under /data, and containers are recreated on every deploy. The template mounts a volume at that path already.


Template Content

More templates in this category

View Template
Garage S3 Storage
Ultra-light S3 server: fast, open-source, plug-and-play.

PROJETOS
8
View Template
Redis
Self Host Latest Redis with Railway

2
View Template
EasyImg
Simple self-hostable Nuxt.js personal image hosting system.

Muhammad Bilal
0