Langfuse v4: up to 165× faster · Read more
Self HostingEnvironment Variables
Version: v4

Environment Variables

Langfuse (self-hosted) has extensive configuration options via environment variables. These need to be passed to all application containers.

VariableRequired / DefaultDescription
DATABASE_URLRequiredConnection string of your Postgres database. Instead of DATABASE_URL, you can also use DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME, and DATABASE_ARGS.
DIRECT_URLDATABASE_URLConnection string of your Postgres database used for database migrations. Use this if you want to use a different user for migrations or use connection pooling on DATABASE_URL. For large deployments, configure the database user with long timeouts as migrations might need a while to complete.
SHADOW_DATABASE_URLIf your database user lacks the CREATE DATABASE permission, you must create a shadow database and configure the "SHADOW_DATABASE_URL". This is often the case if you use a Cloud database. Refer to the Prisma docs for detailed instructions.
CLICKHOUSE_MIGRATION_URLRequiredMigration URL (TCP protocol) for the clickhouse instance. Pattern: clickhouse://<hostname>:(9000/9440)
CLICKHOUSE_MIGRATION_SSLfalseSet to true to establish an SSL connection to Clickhouse for the database migration.
CLICKHOUSE_URLRequiredHostname of the clickhouse instance. Pattern: http(s)://<hostname>:(8123/8443)
CLICKHOUSE_USERRequiredUsername of the clickhouse database. Needs the grants listed under user permissions.
CLICKHOUSE_PASSWORDRequiredPassword of the clickhouse user.
CLICKHOUSE_DBdefaultName of the ClickHouse database to use.
CLICKHOUSE_CLUSTER_ENABLEDtrueWhether to run ClickHouse commands ON CLUSTER. Set to false for single-container setups.
LANGFUSE_AUTO_CLICKHOUSE_MIGRATION_DISABLEDfalseWhether to disable automatic ClickHouse migrations on startup.
CLICKHOUSE_READ_ONLY_URLOptional read-only endpoint used for UI and public-API read queries on traces, observations, scores, and sessions. Falls back to CLICKHOUSE_URL when unset. Reuses CLICKHOUSE_USER, CLICKHOUSE_PASSWORD, and CLICKHOUSE_DB. Primarily useful on compute-compute separated ClickHouse clusters (ClickHouse Cloud, BYOC). See Scaling.
REDIS_CONNECTION_STRINGRequiredConnection string of your redis instance. Instead of REDIS_CONNECTION_STRING, you can also use REDIS_HOST, REDIS_PORT, REDIS_USERNAME and REDIS_AUTH. To configure TLS check the detailed Cache Configuration Documentation.
REDIS_CLUSTER_ENABLEDfalseSet to true to enable Redis cluster mode. When enabled, you must also provide REDIS_CLUSTER_NODES.
REDIS_CLUSTER_NODESComma-separated list of Redis cluster nodes in the format host:port. Required when REDIS_CLUSTER_ENABLED is true. Example: redis-node1:6379,redis-node2:6379,redis-node3:6379.
REDIS_CLUSTER_SLOTS_REFRESH_TIMEOUT5000Timeout in milliseconds for the Redis cluster slots refresh operation. Increase this value if you experience timeout errors during cluster topology updates.
REDIS_SENTINEL_ENABLEDfalseSet to true to enable Redis Sentinel mode. Cannot be enabled simultaneously with cluster mode. When enabled, you must also provide REDIS_SENTINEL_NODES and REDIS_SENTINEL_MASTER_NAME.
REDIS_SENTINEL_NODESComma-separated list of Redis Sentinel nodes in the format host:port. Required when REDIS_SENTINEL_ENABLED is true. Example: sentinel1:26379,sentinel2:26379,sentinel3:26379.
REDIS_SENTINEL_MASTER_NAMEName of the Redis Sentinel master. Required when REDIS_SENTINEL_ENABLED is true. This must match the master name configured in your Sentinel setup.
REDIS_SENTINEL_USERNAMEUsername for Redis Sentinel authentication (optional). Used when Sentinels require authentication.
REDIS_SENTINEL_PASSWORDPassword for Redis Sentinel authentication (optional). Used when Sentinels require authentication.
REDIS_SENTINEL_TLS_ENABLEDfalseSet to true to also apply TLS to the connections to the Sentinel nodes, in addition to the Redis master/replica connections. Requires REDIS_TLS_ENABLED=true; otherwise it is ignored. See Cache Configuration.
REDIS_SOCKET_TIMEOUT_MS30000Socket timeout in milliseconds for all Redis connections including BullMQ queue workers. Set to 0 to disable; positive values must be at least 10000 to accommodate blocking operations like BZPOPMIN. See Cache Configuration.
REDIS_AUTHAuthentication string for the Redis instance or cluster.
NEXTAUTH_URLRequiredPublic URL of your Langfuse web deployment, e.g. https://yourdomain.com or http://localhost:3000. Used for authentication and user-facing links in emails, Slack notifications, and integration settings. Keep it public on web and worker. On >=v4.25.0, use LANGFUSE_MCP_BASE_URL for a separate internal MCP route; if its hostname differs, add it to LANGFUSE_MCP_ALLOWED_HOSTS on web. See Langfuse MCP.
NEXTAUTH_SECRETRequiredUsed to validate login session cookies, generate secret with at least 256 entropy using openssl rand -base64 32.
SALTRequiredUsed to salt hashed API keys, generate secret with at least 256 entropy using openssl rand -base64 32.
ENCRYPTION_KEYRequiredUsed to encrypt sensitive data. Must be 256 bits, 64 string characters in hex format, generate via: openssl rand -hex 32.
LANGFUSE_CSP_ENFORCE_HTTPSfalseSet to true to set CSP headers to only allow HTTPS connections.
PORT3000 / 3030Port the server listens on. 3000 for web, 3030 for worker.
HOSTNAMElocalhostIn some environments it needs to be set to 0.0.0.0 to be accessible from outside the container (e.g. Google Cloud Run).
LANGFUSE_CACHE_API_KEY_ENABLEDtrueEnable or disable API key caching. Set to false to disable caching of API keys. Plain-text keys are never stored in Redis, only hashed or encrypted keys.
LANGFUSE_CACHE_API_KEY_TTL_SECONDS300Time-to-live (TTL) in seconds for cached API keys. Determines how long API keys remain in the cache before being refreshed.
LANGFUSE_CACHE_PROMPT_ENABLEDtrueEnable or disable prompt caching. Set to false to disable caching of prompts.
LANGFUSE_CACHE_PROMPT_TTL_SECONDS300Time-to-live (TTL) in seconds for cached prompts. Determines how long prompts remain in the cache before being refreshed.
LANGFUSE_S3_EVENT_UPLOAD_BUCKETRequiredName of the bucket in which event information should be uploaded.
LANGFUSE_S3_EVENT_UPLOAD_PREFIX""Prefix to store events within a subpath of the bucket. Defaults to the bucket root. If provided, must end with a /.
LANGFUSE_S3_EVENT_UPLOAD_REGIONRegion in which the bucket resides.
LANGFUSE_S3_EVENT_UPLOAD_ENDPOINTEndpoint to use to upload events.
LANGFUSE_S3_EVENT_UPLOAD_ACCESS_KEY_IDAccess key for the bucket. Must have List, Get, and Put permissions.
LANGFUSE_S3_EVENT_UPLOAD_SECRET_ACCESS_KEYSecret access key for the bucket.
LANGFUSE_S3_EVENT_UPLOAD_FORCE_PATH_STYLEWhether to force path style on requests. Required for MinIO.
LANGFUSE_S3_BATCH_EXPORT_ENABLEDfalseWhether to enable Langfuse S3 batch exports. This must be set to true to enable batch exports.
LANGFUSE_S3_BATCH_EXPORT_BUCKETRequiredName of the bucket in which batch exports should be uploaded.
LANGFUSE_S3_BATCH_EXPORT_PREFIX""Prefix to store batch exports within a subpath of the bucket. Defaults to the bucket root. If provided, must end with a /.
LANGFUSE_S3_BATCH_EXPORT_REGIONRegion in which the bucket resides.
LANGFUSE_S3_BATCH_EXPORT_ENDPOINTEndpoint to use to upload batch exports.
LANGFUSE_S3_BATCH_EXPORT_ACCESS_KEY_IDAccess key for the bucket. Must have List, Get, and Put permissions.
LANGFUSE_S3_BATCH_EXPORT_SECRET_ACCESS_KEYSecret access key for the bucket.
LANGFUSE_S3_BATCH_EXPORT_FORCE_PATH_STYLEWhether to force path style on requests. Required for MinIO.
LANGFUSE_S3_BATCH_EXPORT_EXTERNAL_ENDPOINTOptional external endpoint for generating presigned URLs. If not provided, the main endpoint is used. Useful, if langfuse traffic to the blobstorage should remain within the VPC.
BATCH_EXPORT_PAGE_SIZE500Optional page size for streaming exports to S3 to avoid memory issues. The page size can be adjusted if needed to optimize performance.
BATCH_EXPORT_ROW_LIMIT1_500_000Maximum amount of rows that can be exported in a single batch export.
LANGFUSE_S3_MEDIA_UPLOAD_BUCKETRequiredName of the bucket in which media files should be uploaded.
LANGFUSE_S3_MEDIA_UPLOAD_PREFIX""Prefix to store media within a subpath of the bucket. Defaults to the bucket root. If provided, must end with a /.
LANGFUSE_S3_MEDIA_UPLOAD_REGIONRegion in which the bucket resides.
LANGFUSE_S3_MEDIA_UPLOAD_ENDPOINTEndpoint to use to upload media files.
LANGFUSE_S3_MEDIA_UPLOAD_INTERNAL_ENDPOINTOptional endpoint that the Langfuse server can use to read media from object storage. Set this when the public media endpoint is not reachable from the web or worker containers.
LANGFUSE_S3_MEDIA_UPLOAD_ACCESS_KEY_IDAccess key for the bucket. Must have List, Get, and Put permissions.
LANGFUSE_S3_MEDIA_UPLOAD_SECRET_ACCESS_KEYSecret access key for the bucket.
LANGFUSE_S3_MEDIA_UPLOAD_FORCE_PATH_STYLEWhether to force path style on requests. Required for MinIO.
LANGFUSE_S3_MEDIA_MAX_CONTENT_LENGTH1_000_000_000Maximum file size in bytes that is allowed for upload. Default is 1GB.
LANGFUSE_S3_MEDIA_DOWNLOAD_URL_EXPIRY_SECONDS3600Presigned download URL expiry in seconds. Defaults to 1h.
LANGFUSE_S3_CONCURRENT_WRITES50Maximum number of concurrent writes to S3. Useful for errors like @smithy/node-http-handler:WARN - socket usage at capacity=50.
LANGFUSE_S3_CONCURRENT_READS50Maximum number of concurrent reads from S3. Useful for errors like @smithy/node-http-handler:WARN - socket usage at capacity=50.
LANGFUSE_AUTO_POSTGRES_MIGRATION_DISABLEDfalseSet to true to disable automatic database migrations on docker startup. Not recommended.
LANGFUSE_LOG_LEVELinfoSet the log level for the application. Possible values are trace, debug, info, warn, error, fatal.
LANGFUSE_LOG_FORMATtextSet the log format for the application. Possible values are text, json.
LANGFUSE_LOG_PROPAGATED_HEADERSComma-separated list of HTTP header names to propagate through logs via OpenTelemetry baggage. Header names are case-insensitive and will be normalized to lowercase. Useful for debugging and observability. Example: x-request-id,x-user-id.
LANGFUSE_MCP_BASE_URLOptional worker-only base URL for the Langfuse MCP server, available on >=v4.25.0. Takes precedence over NEXTAUTH_URL for MCP endpoint derivation. If its hostname differs from NEXTAUTH_URL, add it to LANGFUSE_MCP_ALLOWED_HOSTS on web. See Langfuse MCP.
LANGFUSE_MCP_ALLOWED_HOSTSComma-separated additional hostnames or origins accepted by the MCP endpoint when a reverse proxy, Docker service name, or Kubernetes service forwards a different Host header than NEXTAUTH_URL. Required for the Langfuse Assistant when LANGFUSE_MCP_BASE_URL uses another hostname. Not needed when web and worker share a public NEXTAUTH_URL the worker can reach. Prefer preserving the public host at the proxy. Values must be exact hostnames or origins; wildcards and paths are not supported.
LANGFUSE_MARKDOWN_RENDER_CHARACTER_LIMIT150000Character count above which trace and observation input/output renders as plain text instead of markdown.

LLM-as-a-Judge media

Self-hosted Langfuse sends media used by LLM-as-a-Judge evaluators inline by default. This lets model providers receive attachments even when they cannot access your object storage. Configure these variables on both the web and worker containers.

VariableRequired / DefaultDescription
LANGFUSE_EVALUATOR_MEDIA_TRANSPORTinlineHow media is sent to the LLM-as-a-Judge model: inline makes the worker download the attachment and send its bytes; url makes the worker create a signed URL without downloading the attachment, so the model provider downloads it; disabled leaves media references as text.
LANGFUSE_EVALUATOR_MEDIA_INLINE_MAX_BYTES20_000_000Maximum size in bytes for each inline attachment. Evaluations fail when an attachment exceeds this limit.

When using inline, set LANGFUSE_S3_MEDIA_UPLOAD_INTERNAL_ENDPOINT if the Langfuse server needs a different object storage address than browsers and SDKs. For example, Docker Compose can use http://localhost:9090 as the public endpoint and http://minio:9000 as the internal endpoint.

Code evaluators

VariableRequired / DefaultDescription
LANGFUSE_CODE_EVAL_DISPATCHERDispatcher used for code evaluator execution and UI availability. Set to aws-lambda for production self-hosted deployments. Set to insecure-local only when all evaluator code is fully trusted.
QUEUE_CONSUMER_CODE_EVAL_EXECUTION_QUEUE_IS_ENABLEDfalseSet to true to enable the worker consumer for the code evaluator execution queue. Required when enabling code evaluator execution.
LANGFUSE_CODE_EVAL_AWS_LAMBDA_NODE_FUNCTION_NAMEcode-based-eval-executor-nodeAWS Lambda function name for TypeScript/JavaScript code evaluator execution when LANGFUSE_CODE_EVAL_DISPATCHER=aws-lambda.
LANGFUSE_CODE_EVAL_AWS_LAMBDA_PYTHON_FUNCTION_NAMEcode-based-eval-executor-pythonAWS Lambda function name for Python code evaluator execution when LANGFUSE_CODE_EVAL_DISPATCHER=aws-lambda.
LANGFUSE_CODE_EVAL_AWS_LAMBDA_ENDPOINTOptional custom AWS Lambda endpoint for local or compatible endpoints.
LANGFUSE_CODE_EVAL_EXECUTION_QUEUE_SHARD_COUNTOptional number of shards for the code evaluator execution queue.
LANGFUSE_CODE_EVAL_EXECUTION_WORKER_CONCURRENCYOptional worker concurrency for code evaluator execution.
LANGFUSE_CODE_EVAL_LOCAL_TIMEOUT_MSOptional timeout in milliseconds for locally executed code evaluators.

Langfuse Assistant

The Assistant is available from >=v4.28.0. It stays hidden until LANGFUSE_IN_APP_AGENT_ENABLED=true is set on the web container and on each worker that should execute Assistant runs. It then uses one instance-wide Langfuse AI model, on Amazon Bedrock, the Anthropic Messages API, an OpenAI-compatible endpoint, or Google Vertex AI (Gemini Enterprise Agent Platform, from >=v4.39.0). We recommend the AWS Lambda MicroVM sandbox. The LANGFUSE_IN_APP_AGENT_SANDBOX_* variables are worker-only. See Langfuse Assistant.

VariableRequired / DefaultDescription
LANGFUSE_IN_APP_AGENT_ENABLEDSet to true on web and on the workers that should execute Assistant runs. Workers with it set consume the run queue. Unset or false hides it. Does not gate Ask AI.
LANGFUSE_AI_PROVIDERRequired to enablebedrock, anthropic, openai, or vertex. Unset leaves Langfuse AI unconfigured.
LANGFUSE_AI_MODELModel ID for the selected provider. On Bedrock, a geo inference profile ID such as eu.anthropic.claude-opus-5. On Vertex, a Claude or Gemini ID such as claude-opus-5.
LANGFUSE_AI_SMALL_MODELOptional model for conversation titles and Ask AI. Defaults to LANGFUSE_AI_MODEL.
LANGFUSE_AI_AWS_BEDROCK_REGIONBedrock Region. Optional when the workload already runs in that Region.
LANGFUSE_AI_VERTEX_LOCATIONglobalVertex location. Optional, defaults to global. Vertex only.
LANGFUSE_AI_API_KEYAPI key. Required when LANGFUSE_AI_PROVIDER is anthropic or openai, not used on Bedrock or Vertex.
LANGFUSE_AI_BASE_URLOptional. Full API base including /v1, such as https://gateway.internal/v1.
LANGFUSE_AI_EXTRA_HEADERSOptional JSON object of additional request headers, on anthropic and openai. Invalid JSON fails validation at boot.
LANGFUSE_AI_USE_RESPONSES_APIOptional. Set to true to call the OpenAI Responses API instead of Chat Completions. openai only.
LANGFUSE_IN_APP_AGENT_RUN_QUEUE_PROCESSING_CONCURRENCY5Concurrent Assistant runs on the worker.
LANGFUSE_IN_APP_AGENT_MAX_ACTIVE_RUNS_PER_USER5Concurrent runs admitted per user on the web service.
LANGFUSE_IN_APP_AGENT_MAX_ACTIVE_RUNS_PER_ORG20Concurrent runs admitted per organization on the web service.
LANGFUSE_AI_FEATURES_PROJECT_IDOptional. Project on this instance that receives Assistant and Ask AI traces. Unset records nothing. See Langfuse Assistant.
LANGFUSE_IN_APP_AGENT_SANDBOX_PROVIDERUnsetSet to lambda-microvm on the worker for production. Unset runs the Assistant with Langfuse tools only.
LANGFUSE_IN_APP_AGENT_SANDBOX_AWS_LAMBDA_MICROVM_IMAGE_IDENTIFIERRequiredMicroVM image ARN. Required when the sandbox provider is lambda-microvm.
LANGFUSE_IN_APP_AGENT_SANDBOX_AWS_LAMBDA_MICROVM_EXECUTION_ROLE_ARNRequiredMicroVM execution role ARN. Required when the sandbox provider is lambda-microvm.
LANGFUSE_IN_APP_AGENT_SANDBOX_AWS_LAMBDA_MICROVM_REGIONRequiredAWS Region for the MicroVM. Required when the sandbox provider is lambda-microvm.
LANGFUSE_IN_APP_AGENT_SANDBOX_AWS_LAMBDA_MICROVM_EGRESS_NETWORK_CONNECTOR_ARNUnsetOptional egress network connector ARN. When unset, AWS attaches INTERNET_EGRESS and sandboxed code reaches the public internet. See Langfuse Assistant.

Additional Features

There are additional features that can be enabled and configured via environment variables.


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