Langfuse launches AI Gateway Learn more
Self HostingLocal/VM (Docker Compose)
Version: v4

Docker Compose

This guide will walk you through deploying Langfuse locally or on a VM using Docker Compose. We will use the docker-compose.yml file.

Docker Compose is for local use and for a single test VM. It runs all seven services on one machine and has no high availability, scaling or backup. For production, use Kubernetes (Helm) or the AWS, Azure or GCP guides. Self-hosted Enterprise can be bundled with ClickHouse Cloud or ClickHouse BYOC, see self-hosted pricing.

If you would rather not run any infrastructure, use Langfuse Cloud: hosted by Langfuse, with a free tier and no infrastructure to run. The SDKs and integrations work identically against Langfuse Cloud and a self-hosted instance.

For local development and coding agent sandboxes that do not need the full platform, langfuse-lite (beta) runs without any infrastructure.

If you use a cloud provider like AWS, GCP, or Azure, you will need permissions to deploy virtual machines.

Coming from docker-compose v2? See our upgrade guide for docker compose.

Walkthrough

Watch this 2:15 minute walkthrough for a step-by-step guide on running Langfuse locally with Docker Compose.

Sizes

ItemSize
Services7: web, worker, AI Gateway, ClickHouse, MinIO, Redis, Postgres
Images to downloadabout 980 MB compressed (web 235 MB, worker 173 MB, AI Gateway 28 MB, ClickHouse 267 MB, MinIO 64 MB, Redis 44 MB, Postgres 167 MB)
VMat least 4 cores, 16 GiB memory, 100 GiB disk, for example a t3.xlarge on AWS
Ports on the host3000 (web), 9090 (MinIO), 3031 (AI Gateway)

Production deployments size each service separately. The scaling page lists the minimums per service.

Get Started

Requirements

  • git
  • a POSIX shell with openssl (on Windows, use WSL or Git Bash)
  • docker & docker compose -> use Docker Desktop on Mac or Windows

Clone Langfuse Repository

Get a copy of the latest Langfuse repository:

git clone https://github.com/langfuse/langfuse.git
cd langfuse

Create the secrets

Run this in the langfuse folder. It writes a .env with a random value for every secret the compose file marks # CHANGEME, and it leaves an existing .env untouched.

if [ -f .env ]; then echo ".env exists, not overwriting"
elif ! command -v openssl >/dev/null; then echo "openssl not found, install it first"
else
PG=$(openssl rand -hex 16)
MINIO=$(openssl rand -hex 16)
cat > .env <<ENV
DATABASE_URL=postgresql://postgres:${PG}@postgres:5432/postgres
POSTGRES_PASSWORD=${PG}
SALT=$(openssl rand -hex 16)
ENCRYPTION_KEY=$(openssl rand -hex 32)
NEXTAUTH_SECRET=$(openssl rand -hex 32)
CLICKHOUSE_PASSWORD=$(openssl rand -hex 16)
REDIS_AUTH=$(openssl rand -hex 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}
ENV
fi

DATABASE_URL contains the Postgres password, and the three S3 secret keys must equal the MinIO root password, so the script sets each pair from one value. Do not put spaces around = in .env. If you started Langfuse on this machine before with the default secrets, the existing volumes keep the old passwords: remove them with docker compose down -v, which deletes all data.

Start Langfuse

docker compose up -d

Wait until it is ready

ok=; for i in $(seq 1 60); do curl -sf http://localhost:3000/api/public/health && { ok=1; break; }; sleep 5; done
[ -n "$ok" ] || echo "Not ready after 5 minutes, check: docker compose logs langfuse-web"
docker compose ps

The health check prints {"status":"OK","version":"..."} once the web container is up, usually after 2 to 3 minutes.

Done

And you are ready to go! Open http://localhost:3000 in your browser to access the Langfuse UI.

There is no default login. Langfuse does not ship with a built-in admin account or password. Click Sign up on the login page to create the first user, then create your organization and project in the UI. To pre-create the organization, project, API keys, and first user without the UI, use headless initialization.

Start a new instance and SSH into it

Enter your cloud provider interface and navigate to the VM instance section. This is EC2 on AWS, Compute Engine on GCP, and Virtual Machines on Azure. Create a new instance.

Choose an instance that matches the VM size. Assign a public IP address in case you want to send traces from external sources.

The rest of this guide will assume that you have an Ubuntu OS running on your VM and are connected via SSH.

Install Docker and Docker Compose

Install docker (see official guide as well). Setup Docker's apt repository:

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

Install Docker packages:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Verify installation:

sudo docker run hello-world

Clone Langfuse Repository

Get a copy of the latest Langfuse repository:

git clone https://github.com/langfuse/langfuse.git

cd langfuse

Create the secrets

Run this in the langfuse folder. It writes a .env with a random value for every secret the compose file marks # CHANGEME, and it leaves an existing .env untouched. Before you run it, replace <instance-ip> with the instance address, because NEXTAUTH_URL must match the address users open.

if [ -f .env ]; then echo ".env exists, not overwriting"
elif ! command -v openssl >/dev/null; then echo "openssl not found, install it first"
else
PG=$(openssl rand -hex 16)
MINIO=$(openssl rand -hex 16)
cat > .env <<ENV
NEXTAUTH_URL=http://<instance-ip>:3000
DATABASE_URL=postgresql://postgres:${PG}@postgres:5432/postgres
POSTGRES_PASSWORD=${PG}
SALT=$(openssl rand -hex 16)
ENCRYPTION_KEY=$(openssl rand -hex 32)
NEXTAUTH_SECRET=$(openssl rand -hex 32)
CLICKHOUSE_PASSWORD=$(openssl rand -hex 16)
REDIS_AUTH=$(openssl rand -hex 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}
ENV
fi

DATABASE_URL contains the Postgres password, and the three S3 secret keys must equal the MinIO root password, so the script sets each pair from one value. Do not put spaces around = in .env. If you started Langfuse on this machine before with the default secrets, the existing volumes keep the old passwords: remove them with docker compose down -v, which deletes all data.

Update network parameters (optional)

Only the langfuse-web container and minio must be accessible from outside the instance. Therefore, we recommend to add a security group or firewall to your instance that restricts incoming traffic to port :3000 and :9090. If you use the AI Gateway, allow traffic to the TLS-terminating reverse proxy in front of it rather than to port :3031, because the gateway serves plain HTTP. Host firewalls such as ufw don't filter ports that Docker publishes, so block :3031 in the security group or bind it to 127.0.0.1 in docker-compose.yml.

Start Langfuse

docker compose up -d

Wait until it is ready

ok=; for i in $(seq 1 60); do curl -sf http://localhost:3000/api/public/health && { ok=1; break; }; sleep 5; done
[ -n "$ok" ] || echo "Not ready after 5 minutes, check: docker compose logs langfuse-web"
docker compose ps

The health check prints {"status":"OK","version":"..."} once the web container is up, usually after 2 to 3 minutes.

Done

And you are ready to go! Open http://<instance-ip>:3000 in your browser to access the Langfuse UI.

There is no default login. Langfuse does not ship with a built-in admin account or password. Click Sign up on the login page to create the first user, then create your organization and project in the UI. To pre-create the organization, project, API keys, and first user without the UI, use headless initialization.

Depending on your configuration, you might need to open an SSH tunnel to your VM to access the IP. Please refer to your cloud provider's documentation for how to do this.

Docker log rotation

The default docker-compose.yml inherits the Docker daemon's logging configuration. Docker's default json-file driver does not rotate logs unless configured, which can exhaust disk space. Set its max-size and max-file options, or keep your chosen logging backend and configure retention there. Do not rotate or truncate Docker-managed JSON log files with external tools.

After changing daemon logging defaults, restart Docker and recreate existing containers to apply them; restarting containers alone is insufficient. Plan for interruption and preserve data volumes. These settings cover container stdout/stderr, not database data volumes or ClickHouse's internal log files.

AI Gateway

The default docker-compose.yml includes the AI Gateway (beta) as the langfuse-ai-gateway service, listening on port 3031. It needs Langfuse newer than v4.75.0; LANGFUSE_IMAGE_TAG sets the tag of web, worker, and gateway together. The gateway stays idle, with 503 on /ready, until you add its two keys to .env:

# Start on a new line if .env doesn't end with one.
[ -n "$(tail -c1 .env 2>/dev/null)" ] && echo >> .env
echo "LANGFUSE_AI_GATEWAY_SERVICE_KEY=$(openssl rand -hex 32)" >> .env
printf '%s\n' "LANGFUSE_AI_GATEWAY_JWT_PRIVATE_KEY='$(openssl ecparam -name prime256v1 -genkey -noout | awk '{printf "%s\\n", $0}')'" >> .env
docker compose up -d --pull always

Web shows http://localhost:3031 as the gateway's public URL, which only works on the Docker host. On a remote host, or whenever users reach Langfuse from other machines, set LANGFUSE_AI_GATEWAY_PUBLIC_URL in .env to the address clients use, and put a TLS-terminating reverse proxy in front of the gateway.

If you build web yourself, for example for a custom base path, rebuild it from a supported release and omit --pull always, which would replace your image. For TLS, other settings, and key rotation, see the AI Gateway guide.

Features

Langfuse supports many configuration options and self-hosted features. For more details, please refer to the configuration guide.

Scaling

Docker compose does not support horizontal scaling without an additional Load Balancer component. We recommend to use one of the other deployment options if your load exceeds single-instance scale or requires high availability. To add more throughput on a docker compose setup, you can usually use a larger virtual machine, i.e. scale vertically.

Shutdown

Stop all containers with:

docker compose down

Adding the -v flag will also remove the volumes.

Ensure to stop the VM instance in your cloud provider interface to avoid unnecessary costs.

Changing the exposed ports

The default docker-compose.yml publishes two services on the host: the Langfuse UI on port 3000 (langfuse-web, mapping 3000:3000) and MinIO on port 9090 (mapping 9090:9000). If one of these ports is already taken on your machine, change the host side of the mapping (the left value) and leave the container side unchanged, for example 3001:3000 for the UI.

When you change a port, also update the URLs that point at it:

  • NEXTAUTH_URL must match the URL users open in the browser, for example http://localhost:3001. Langfuse uses it for authentication callbacks and for links in the UI and in emails.
  • LANGFUSE_S3_MEDIA_UPLOAD_ENDPOINT on langfuse-web defaults to http://localhost:9090 and must point at the new MinIO host port, because browsers upload and download media through this URL.
  • The AI Gateway publishes port 3031. To change it, set LANGFUSE_AI_GATEWAY_PORT in .env; its port mapping and default public URL follow it.

Ports that are bound to 127.0.0.1 (the worker on 3030, MinIO console on 9091, and the databases) are only reachable from the host itself and usually do not need to change.

Troubleshooting

  • Multimodal tracing is not working: This docker compose setup by default uses MinIO for blob storage which is not accessible from outside the Docker network for direct uploads. Please refer to the blob storage guide for more details on how to configure MinIO for media uploads.
  • Make sure that the VM has enough disk space for accumulating traces.

How to Upgrade

To upgrade Langfuse, you can stop the containers and run docker compose up -d --pull always.

For more details on upgrading, please refer to the upgrade guide.


If you experience any issues when self-hosting Langfuse, please:

  1. Check out Troubleshooting & FAQ page.
  2. Use Ask AI to get instant answers to your questions.
  3. Ask the maintainers on GitHub Discussions.
  4. Create a bug report or feature request on GitHub.

Enterprise-grade support is available when self-hosting Langfuse. Learn more on our pricing page.


Was this page helpful?

Last updated on