Self-Hosted Langfuse in Docker: Install, Upgrade, Back Up

By Updated

What is self-hosted Langfuse?

Self-hosted Langfuse is a platform for tracing and evaluating LLM applications that runs on your own server. Version v4 consists of the web and worker containers and four stores: PostgreSQL, ClickHouse, Redis and S3-compatible storage; the official compose file also includes an AI Gateway in beta. The core is MIT-licensed, and some enterprise features require a key.

TL;DR

  • -A working minimum: the compose file and images from one exact tag (v4.88.0 as of November 29, 2026), random secrets in .env, a port override to 127.0.0.1, web and worker started without the AI Gateway, and a test trace followed all the way to the database.
  • -In the author's test, an empty six-container stack came up in 34 s and used about 2.4 GiB of memory. The documentation asks for 16 GiB; there is no measurement with users, evaluations or large queries.
  • -Rolling back by changing the tag from 4.88.0 to 4.78.0 failed: web went into a restart loop with "no migration found for version 61". A cold backup of all volumes was restored to a passing health check in 23 s.
  • -While Redis is stopped, ingestion doesn't return an error, it hangs: two sends took 601 s and the data was not saved. The client needs its own timeout.
  • -Changing SALT invalidates API keys (401), and a short ENCRYPTION_KEY keeps web from starting. A backup without .env is useless.

Self-hosted Langfuse is a platform for tracing and evaluating LLM applications on your own server. Version v4 runs in Docker Compose as seven services, and the data sits in four stores at once. The steps, in order:

  1. Take the compose file and images from one exact tag and generate secrets.
  2. Close the ports with an override file: nothing should be reachable from outside.
  3. Start web and worker, then wait for a health check that includes the database.
  4. Send a test trace and find it in ClickHouse.
  5. Take a cold backup of all volumes together with .env, before the first upgrade.

What was tested and what wasn’t. The test ran on November 29, 2026 on a Linux server (8 vCPU, 23 GB, Docker 29.2.1, Compose 5.0.2), one run each: the compose file from tag v4.88.0, images 4.78.0 and 4.88.0, all external ports closed, the AI Gateway not started. It covered startup, ingestion, a Redis outage, backup, upgrade, rollback, restore and damaged secrets. The files below were rewritten for a permanent install and have not been run in this form: bash and YAML syntax and consistency with the compose file were checked. The UI, SSO, HTTPS, migration from v3 and operation under load were not tested.

For what traces are, how to connect the Python SDK and how prompt versions work, see the step-by-step Langfuse guide. This article covers operations only.

What Langfuse v4 consists of

Components are from the documentation and the v4.88.0 compose file, image sizes from the test:

ServiceWhat it doesImageOn disk
langfuse-webUI, API, trace ingestionlangfuse:4.88.01.04 GB
langfuse-workerqueue processinglangfuse-worker:4.88.0803 MB
clickhousetraces, observations, scoresclickhouse-server:26.3.62.31.19 GB
postgresusers, projects, keys, promptspostgres:17671 MB
minioraw events, media, exportschainguard/minio, no tag236 MB
redisqueue and cacheredis:7not recorded
langfuse-ai-gatewayproxy to providers, betaai-gateway:4.88.0not started

The storage tags differ in strictness: ClickHouse is pinned to a patch, Postgres and Redis to a major version, and MinIO isn’t pinned at all. Running docker compose pull without service names may update it along with the rest, so the commands below pull only web and worker.

Compose is meant for local use and a single test VM. For production the documentation points to Kubernetes or a cloud.

How much memory you need: 2.4 GiB vs 16

ContainerIdle memory, 4.78.0
web1.32 GiB
worker685 MiB
ClickHouse283 MiB
Postgres80 MiB
MinIO58 MiB
Redis5 MiB
Totalabout 2.4 GiB

After 10,000 spans the stack grew to 2.6 GiB. For the same setup the documentation asks for 4 cores, 16 GiB and 100 GiB of disk, and the scaling page separately allots 4 GiB to web, 4 to worker and 8 to ClickHouse.

The gap doesn’t mean the documentation overstates the requirements. The test had one project, short synthetic spans and nobody opening the UI. ClickHouse uses memory for part merges and queries over long periods, the worker for evaluations and exports, and none of that was running. What the test does show is that a small machine is enough to get to know the interface. Size a production server from the documented requirements and watch docker stats on your own data.

Step 1. Compose file and secrets

The script downloads the file for the chosen tag and creates .env. It is based on the documentation, with pinned versions and headless initialization added:

#!/usr/bin/env bash
# init.sh - run once in an empty directory
set -euo pipefail
umask 077
TAG=4.88.0
[ ! -e .env ] || { echo ".env already exists, exiting" >&2; exit 1; }
curl -fsSLo docker-compose.yml \
  "https://raw.githubusercontent.com/langfuse/langfuse/v$TAG/docker-compose.yml"
r() { openssl rand -hex "$1"; }
PG=$(r 16); MINIO=$(r 16)
cat > .env <<ENV
COMPOSE_PROJECT_NAME=langfuse
LANGFUSE_IMAGE_TAG=$TAG
POSTGRES_VERSION=17
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=$(r 32)
SALT=$(r 32)
ENCRYPTION_KEY=$(r 32)
POSTGRES_PASSWORD=$PG
DATABASE_URL=postgresql://postgres:$PG@postgres:5432/postgres
CLICKHOUSE_PASSWORD=$(r 16)
REDIS_AUTH=$(r 16)
MINIO_ROOT_PASSWORD=$MINIO
LANGFUSE_S3_EVENT_UPLOAD_SECRET_ACCESS_KEY=$MINIO
LANGFUSE_S3_MEDIA_UPLOAD_SECRET_ACCESS_KEY=$MINIO
LANGFUSE_S3_BATCH_EXPORT_SECRET_ACCESS_KEY=$MINIO
TELEMETRY_ENABLED=false
AUTH_DISABLE_SIGNUP=true
LANGFUSE_INIT_ORG_ID=main
LANGFUSE_INIT_PROJECT_ID=app
LANGFUSE_INIT_PROJECT_PUBLIC_KEY=pk-lf-$(r 16)
LANGFUSE_INIT_PROJECT_SECRET_KEY=sk-lf-$(r 16)
[email protected]
LANGFUSE_INIT_USER_PASSWORD=$(r 16)
ENV

What is easy to break here:

  • Paired values. The Postgres password is repeated in DATABASE_URL, and the three S3 keys must match MINIO_ROOT_PASSWORD.
  • SALT. It’s used to hash API keys. In the test, after the value changed, the same request got a 401.
  • ENCRYPTION_KEY. Exactly 64 hex characters. With a short key web didn’t start: “ENCRYPTION_KEY must be 256 bits, 64 string characters in hex format”. This key encrypts saved LLM provider keys, so if you lose it you’ll have to enter them again (a conclusion from the documentation, not tested).
  • Quotes. The documentation asks not to put LANGFUSE_INIT_* values in double quotes.
  • Restarting with different passwords. The volumes remember the old ones. The documentation suggests docker compose down -v, but that erases the data.

TELEMETRY_ENABLED=false turns off aggregated telemetry. Replace the email with your own. The author didn’t create a user in the test: there, initialization set up the organization, the project and the keys.

Step 2. Override: all ports on localhost

The compose file publishes ports 3000, 9090 and 3031 on all interfaces. ufw won’t help: the documentation warns that such firewalls don’t filter ports published by Docker. Compose picks up docker-compose.override.yml automatically:

services:
  langfuse-web:
    ports: !override
      - "127.0.0.1:3000:3000"
    environment:
      AUTH_DISABLE_SIGNUP: ${AUTH_DISABLE_SIGNUP:-false}
  minio:
    ports: !override
      - "127.0.0.1:9090:9000"
  langfuse-ai-gateway:
    ports: !reset []
  postgres:
    ports: !reset []
  clickhouse:
    ports: !reset []
  redis:
    ports: !reset []

The tags are required. Without them Compose appends port lists, and 0.0.0.0 stays next to the new line. !reset [] worked in the test on all seven services; !override is taken from the Compose documentation. Worker port 3030 is already bound to 127.0.0.1 in the original file.

The environment block is there for a different reason: the v4.88.0 compose file has no AUTH_DISABLE_SIGNUP variable, so without the block the line in .env silently does nothing. Disabled sign-up also applies to invited people who don’t have an account yet.

Step 3. Start and first login

set -euo pipefail
docker compose config -q
docker compose pull langfuse-web langfuse-worker
docker compose up -d langfuse-web langfuse-worker
curl -fsS --retry 60 --retry-delay 5 --retry-all-errors --max-time 5 \
  'http://127.0.0.1:3000/api/public/health?failIfDatabaseUnavailable=true'
docker compose ps
ss -ltn | grep -E ':(3000|3030|3031|9090|9091|5432|6379|8123|9000)\b'

The stores start on their own through depends_on, and the AI Gateway won’t start. In the output of the last line, expect only 127.0.0.1. In the test with empty volumes, health responded after 34 s and the images took 24 s to download; the documentation promises 2-3 minutes.

The failIfDatabaseUnavailable parameter matters: plain /api/public/health checks only the API and returns OK while the database is down. The page promises nothing about Redis in either case.

Open the UI through an SSH tunnel (ssh -L 3000:127.0.0.1:3000 server) and log in as the user from .env. For team access, put an HTTPS proxy in front of port 3000 and change NEXTAUTH_URL to the public address: it must match what the browser opens. The browser uploads media directly to MinIO, so you’ll also need an external LANGFUSE_S3_MEDIA_UPLOAD_ENDPOINT.

Step 4. Check ingestion all the way to the database

Web puts events in S3 and a reference to them in the queue; the worker writes them to ClickHouse. A 200 response is therefore not enough, and the check has to look for the row in the database:

#!/usr/bin/env bash
# smoke.sh
set -euo pipefail
v() { sed -n "s/^$1=//p" .env; }
curl -fsS --retry 60 --retry-delay 5 --retry-all-errors --max-time 5 \
  'http://127.0.0.1:3000/api/public/health?failIfDatabaseUnavailable=true'
N="smoke-$(openssl rand -hex 4)"; NOW=$(date +%s)
BODY=$(printf '{"resourceSpans":[{"resource":{"attributes":[]},"scopeSpans":[{"scope":{"name":"smoke"},"spans":[{"traceId":"%s","spanId":"%s","name":"%s","kind":1,"startTimeUnixNano":"%s000000000","endTimeUnixNano":"%s000000000"}]}]}]}' \
  "$(openssl rand -hex 16)" "$(openssl rand -hex 8)" "$N" "$NOW" "$NOW")
printf 'user = "%s:%s"\n' "$(v LANGFUSE_INIT_PROJECT_PUBLIC_KEY)" \
    "$(v LANGFUSE_INIT_PROJECT_SECRET_KEY)" |
  curl -sS --max-time 10 -K - -o /dev/null -w 'HTTP %{http_code}\n' \
    -H 'content-type: application/json' -H 'x-langfuse-ingestion-version: 4' \
    --data "$BODY" http://127.0.0.1:3000/api/public/otel/v1/traces
sleep 40
# shellcheck disable=SC2016
docker compose exec -T clickhouse sh -c 'clickhouse-client --user "$CLICKHOUSE_USER" \
  --password "$CLICKHOUSE_PASSWORD" --param_n="$1" \
  -q "SELECT count() FROM events_core WHERE name = {n:String}"' _ "$N"

The script waits for health first, then should print HTTP 200 and 1. The key goes through stdin so it doesn’t show up in the process list. The x-langfuse-ingestion-version: 4 header is needed for real-time display: without it, OpenTelemetry data can lag by up to 10 minutes.

In the test, 10,000 spans in batches of 100 went out in 2.6 s, all accepted. After 40 s, events_core and events_full each held 10,100 rows, including a hundred test spans. The observations table stayed empty because v4 writes to events_*. Old monitoring scripts that count rows in observations will show zero on a new install. A wrong key got a 401.

If Redis goes down, requests hang

With Redis stopped, ingestion returned neither 500 nor 503. Two sends in a row waited until the client timeout fired, 601 s in total, and those events never appeared in the database. After Redis started, the next sends went through without restarting web.

What this means for the application:

  • A timeout in every client. The test sent requests with Node fetch and no timeout, hence the minutes of waiting. The Python SDK defaults to 5 s (LANGFUSE_TIMEOUT), and OpenTelemetry exporters to 10 s per the specification. Set a timeout explicitly in custom senders.
  • Tracing outside the user response path. Synchronous sending without a timeout will stall the application itself.
  • A separate check. Run smoke.sh on a schedule: health may stay green during such a failure. The documentation also describes ?failIfQueueConsumptionStuck=true on the worker; it was not tested.

Step 5. Cold backup of all volumes

The backups page describes the stores separately, says nothing about Redis or restore order, and its pg_dump example uses the langfuse user, which doesn’t exist in the official compose file: the user there is postgres. On a single machine it’s simpler to stop the stack and copy all volumes at once, so the stores are consistent with each other.

#!/usr/bin/env bash
# backup.sh
set -euo pipefail
umask 077
TAG=$(sed -n 's/^LANGFUSE_IMAGE_TAG=//p' .env)
B="$PWD/backup/$(date +%Y%m%d-%H%M%S)-$TAG"
mkdir -p "$B"
cp .env docker-compose.yml docker-compose.override.yml "$B/"
docker compose images > "$B/images.txt"
trap 'docker compose up -d langfuse-web langfuse-worker' EXIT
docker compose stop langfuse-web langfuse-worker
docker compose exec -T postgres pg_dump -U postgres -Fc postgres > "$B/pg.dump"
docker compose stop
for v in $(docker volume ls -q --filter label=com.docker.compose.project=langfuse); do
  docker run --rm --network none -v "$v":/d:ro -v "$B":/b docker.io/postgres:17 \
    tar --numeric-owner -C /d -czf "/b/$v.tgz" .
done
(cd "$B" && sha256sum -- *.tgz pg.dump > SHA256SUMS)
echo "$B"

trap brings the stack back up even if copying fails. In the test the same procedure (with a different helper image) took 12 s for 10,100 events:

WhatSize
ClickHouse26.6 MB
Postgres, volume7.6 MB
Postgres, pg_dump -Fc395 KB
MinIO258 KB
Redis9 KB

pg_dump here is insurance against a damaged volume. The author didn’t try restoring Postgres alone next to a newer ClickHouse. The copy contains .env with every secret, so keep it in encrypted storage off the server.

Step 6. Upgrade 4.78.0 → 4.88.0

Releases come out almost daily: between 4.78.0 (November 10) and 4.88.0 (November 26) there were 16 days and 10 minor versions. The documentation suggests tracking the 4 tag. The tag here is exact, so you know what to return to; that is this article’s position, not the vendor’s.

set -euo pipefail
./backup.sh
NEW=4.88.0
curl -fsSLo docker-compose.new.yml \
  "https://raw.githubusercontent.com/langfuse/langfuse/v$NEW/docker-compose.yml"
diff docker-compose.yml docker-compose.new.yml || true   # read it yourself
mv docker-compose.new.yml docker-compose.yml
sed -i "s/^LANGFUSE_IMAGE_TAG=.*/LANGFUSE_IMAGE_TAG=$NEW/" .env
docker compose pull langfuse-web langfuse-worker
docker compose up -d langfuse-web langfuse-worker
./smoke.sh
docker compose logs langfuse-web | grep -i migrat | tail -4

Web runs fast migrations at startup, and the worker runs long ones in the background: click the version in the UI and open Background Migrations to see their status. It’s better to start the next upgrade after they finish. In the test the new version responded after 25 s, migrations were applied, the 10,100 events were still there, and another hundred were accepted.

Rollback: three products, three behaviors

The author tried the same thing, putting the old tag back on an upgraded database, on three self-hosted products:

LangfuseOpen WebUIn8n
Rollback4.88.0 → 4.78.00.13.5 → 0.12.52.49.8 → 2.40.0
DatabasePostgres + ClickHouseSQLiteSQLite
Old tag on the new schemaweb in a restart loop, worker runningdoesn’t startstarts silently in 12 s
What you see”no migration found for version 61""Can’t locate revision identified by ‘5e7a2c9d4b13‘“no schema errors
Restoring the backuphealth in 23 s, 10,100 eventsstarts, old token acceptedstarts, credentials readable

The Langfuse log during rollback:

474 migrations found in prisma/migrations
No pending migrations to apply.
error: no migration found for version 61: read down for version 61 .: file does not exist
Applying clickhouse migrations failed. Common causes:
  1. The database is unavailable or unreachable.
  2. CLICKHOUSE_PASSWORD contains special characters that are not URL-encoded.

This log has two traps. The hints at the end point to the password and the network, although the cause is the schema. The second trap is in the first two lines: the old image knows 474 Postgres migrations and tag 4.88.0 has 504, but Prisma didn’t object to the extra thirty. Only ClickHouse stopped the startup.

Judging by the repository, the last ClickHouse migration is number 56 in tags 4.78.0-4.83.0, 59 in 4.84.0 and 61 in 4.85.0-4.88.0. So between 4.85.0 and 4.88.0 this check won’t fire, and an old image may start on a newer Postgres schema as quietly as n8n does. This is a conclusion from the code; no such pair was run.

The failed rollback didn’t damage the data: ClickHouse still had 10,200 events. The author didn’t try going back to tag 4.88.0 afterwards and restored the copy right away.

Restoring from a backup

First run backup.sh on the new version too: events after the old copy will be lost. In the test that is how the hundred events sent on 4.88.0 disappeared.

set -euo pipefail
B="$PWD/backup/20261129-120000-4.78.0"
(cd "$B" && sha256sum -c SHA256SUMS)   # before deleting anything
docker compose down                    # without -v
cp "$B/.env" "$B/docker-compose.yml" "$B/docker-compose.override.yml" .
for f in "$B"/langfuse_*.tgz; do
  v=$(basename "$f" .tgz)
  docker volume inspect "$v" > /dev/null
  docker run --rm --network none -v "$v":/d -v "$B":/b:ro docker.io/postgres:17 \
    sh -c 'find /d -mindepth 1 -delete && tar --numeric-owner -C /d -xzf "/b/$1.tgz"' _ "$v"
done
docker compose up -d langfuse-web langfuse-worker
./smoke.sh

The loop wipes each volume before unpacking, so the checksums come first. Volume order doesn’t matter: the stack is stopped and all copies were taken at one point. Moving to another server was not tested.

If you’re on v3

Security patches for v3 continue until January 31, 2027. The move to v4 is described in the official guide; the author hasn’t done it. The main points from there:

  • ClickHouse 25.12 or newer, Postgres from 15, Redis from 7.0.
  • First the latest v3 and all background migrations: SELECT name FROM background_migrations WHERE finished_at IS NULL; must return zero rows, otherwise v4 permanently deletes what hasn’t been transferred.
  • Back up Postgres and ClickHouse right before the upgrade. Simply switching the image back doesn’t work; you can return the schema with migrate ... goto 37 while the legacy or dual write mode is on.
  • Automatic history transfer needs about three times the current ClickHouse volume on disk.

SDKs, ingestion and license

Python SDK v5 and JS/TS SDK v6 require server 4.59.0 or newer; Python SDK v4 works from 3.63.0. Current versions as of November 29, 2026: langfuse 5.2.0 (Python 3.11+) and @langfuse/client 6.1.1. OTLP is accepted over HTTP in JSON and protobuf; gRPC isn’t supported.

Code outside the ee/ directories is MIT-licensed, copyright ClickHouse, Inc. The LANGFUSE_EE_LICENSE_KEY key unlocks data retention policies, audit logs, project-level roles, protected prompt labels, server-side masking, SCIM and the Instance Management API. Without it traces are kept indefinitely, so watch the disk yourself.

Security

As of November 29, 2026, the repository lists four published advisories: three medium and one low, the newest from April 17. All are fixed in the v3 branch (the last one in 3.167.0); they say nothing separate about v4.

The minimum for a server: ports on 127.0.0.1, sign-up disabled, HTTPS on the proxy, .env with mode 600, Docker log rotation (json-file doesn’t rotate by default) and disk space monitoring. Mask personal data before sending it: server-side masking is available only with a key.

Common errors

SymptomCauseWhat to do
”no migration found for version N”old image on a new schemareturn the new tag or restore the backup
401 on working keysSALT changedrestore the previous .env
”ENCRYPTION_KEY must be 256 bits”not 64 hex charactersopenssl rand -hex 32, but only on an empty install
A send hangs without a responseRedis unavailableclient timeout, docker compose logs redis
HTTP 200, empty UIqueue not processed or the version header is missingworker logs, the x-langfuse-ingestion-version: 4 header
Sign-up is open although .env forbids itthe compose file doesn’t pass the variablethe environment block in the override
”JavaScript heap out of memory”Node heap too smallNODE_OPTIONS=--max-old-space-size
Media doesn’t uploadthe browser can’t reach MinIOLANGFUSE_S3_MEDIA_UPLOAD_ENDPOINT

The first four rows come from the test, the rest from the documentation and the compose file.

What to do on the first day

Bring up the stack, run smoke.sh, take a backup and restore it right away on the same empty install, while there’s nothing to lose. Then connect the application: first traces and prompts, agent tool tracing. If four stores look expensive just for traces, price the cloud version or a lighter tool.

Frequently Asked Questions

How much memory does self-hosted Langfuse need?
The Docker Compose documentation gives a minimum of 4 cores, 16 GiB of memory and 100 GiB of disk. In the author's test, an empty 4.78.0 stack used about 2.4 GiB, and 2.6 GiB after 10,000 spans. This was one run without users, evaluations or heavy queries, so it can't be used to size a production server.
Can you roll Langfuse back to an earlier version?
Reliably only together with the data: restore the previous tag and the volumes from a backup taken before the upgrade. In the author's test, the old 4.78.0 tag did not start on a database that had run 4.88.0, because of ClickHouse migrations. Everything that arrived after the backup is lost in such a rollback.
Where does Langfuse store data?
Users, projects, keys and prompts are in PostgreSQL; traces, observations and scores are in ClickHouse; raw events and media are in S3 storage (MinIO in the compose file). Redis holds the cache and the queue. A full backup needs all four stores and the .env file.
Is self-hosted Langfuse free?
Yes. The Open Source version under MIT has no volume limit and includes tracing, prompts, datasets and evaluations. A license key is needed for Enterprise features: data retention policies, audit logs, project-level roles, server-side masking and SCIM. The key is set in the LANGFUSE_EE_LICENSE_KEY variable.
Can I use Valkey instead of Redis?
Yes, Valkey 8 and newer is officially supported, and it is the default in the Helm chart. The eviction policy must be noeviction, otherwise the store will delete queue jobs. The author's test ran Redis 7 from the official compose file.
Is Docker Compose suitable for production Langfuse?
The documentation reserves Compose for local use and a single test VM: it has no high availability, scaling or backups. For production it recommends Kubernetes via Helm or templates for AWS, Azure and GCP. If you stay on Compose, backups and restore tests are your job.