Environment variables
In general, environment variables, like LANGFLOW_PORT or LANGFLOW_LOG_LEVEL, configure how Langflow runs.
These are broad settings that apply to your entire Langflow deployment.
In contrast, global variables are user-defined values stored in Langflow's database for use in flows, such as OPENAI_API_KEY.
Langflow can also source global variables from environment variables.
For more information, see Langflow global variables.
Configure environment variables for Langflow OSS
Langflow recognizes supported environment variables from the following sources:
- Environment variables set in your terminal.
- Environment variables imported from a
.envfile when starting Langflow. - Environment variables set with the Langflow CLI, including the
--env-fileoption and direct options, such as--port.
You can choose to use one or more of these sources.
Precedence
If the same environment variable is set in multiple places, the following hierarchy applies:
- Langflow CLI options override all other sources.
- The
.envfile overrides system environment variables. - System environment variables are used only if not set elsewhere.
When running a Langflow Docker image, the
-eflag can be used to set additional system environment variables.
For example:
- If you set
LANGFLOW_PORT=8080in your system environment andLANGFLOW_PORT=7860in.env, Langflow uses7860from.env. - If you use the Langflow CLI to run
langflow run --env-file .env --port 9000, and you setLANGFLOW_PORT=7860in.env, then Langflow uses9000from the CLI option.
Set environment variables in your terminal
Run the following commands to set environment variables for your current terminal session:
- Linux or macOS
- Windows
- Docker
_10export VARIABLE_NAME='VALUE'
_10set VARIABLE_NAME='VALUE'
_10docker run -it --rm \_10 -p 7860:7860 \_10 -e VARIABLE_NAME='VALUE' \_10 langflowai/langflow:latest
When you start Langflow, it looks for environment variables that you've set in your terminal. If it detects a supported environment variable, then it automatically adopts the specified value, subject to precedence rules.
Import environment variables from a .env file
-
If Langflow is running, quit Langflow.
-
Create a
.envfile, and then open it in your preferred editor. -
Define Langflow environment variables in the
.envfile.Example: .env
_29DO_NOT_TRACK=True_29LANGFLOW_AUTO_LOGIN=False_29LANGFLOW_AUTO_SAVING=True_29LANGFLOW_AUTO_SAVING_INTERVAL=1000_29LANGFLOW_BACKEND_ONLY=False_29LANGFLOW_BUNDLE_URLS=["https://github.com/user/repo/commit/hash"]_29LANGFLOW_CACHE_TYPE=async_29LANGFLOW_COMPONENTS_PATH=/path/to/components/_29LANGFLOW_CONFIG_DIR=/path/to/config/_29LANGFLOW_DATABASE_URL=postgresql://user:password@localhost:5432/langflow_29LANGFLOW_DEV=False_29LANGFLOW_FALLBACK_TO_ENV_VAR=False_29LANGFLOW_HEALTH_CHECK_MAX_RETRIES=5_29LANGFLOW_HOST=localhost_29LANGFLOW_LANGCHAIN_CACHE=InMemoryCache_29LANGFLOW_MAX_FILE_SIZE_UPLOAD=10000_29LANGFLOW_MAX_ITEMS_LENGTH=100_29LANGFLOW_MAX_TEXT_LENGTH=1000_29LANGFLOW_LOG_LEVEL=error_29LANGFLOW_OPEN_BROWSER=False_29LANGFLOW_PORT=7860_29LANGFLOW_REMOVE_API_KEYS=False_29LANGFLOW_SAVE_DB_IN_CONFIG_DIR=True_29LANGFLOW_SECRET_KEY=somesecretkey_29LANGFLOW_STORE_ENVIRONMENT_VARIABLES=True_29LANGFLOW_SUPERUSER=adminuser_29LANGFLOW_SUPERUSER_PASSWORD=adminpass_29LANGFLOW_WORKER_TIMEOUT=60000_29LANGFLOW_WORKERS=3For additional examples, see
.env.examplein the Langflow repository. -
Save and close
.env. -
Start Langflow with your
.envfile:- Local
- Docker
_10uv run langflow run --env-file .env_10docker run -it --rm \_10-p 7860:7860 \_10--env-file .env \_10langflowai/langflow:latestIf your
.envfile isn't in the same directory, provide the path to your.envfile.
On startup, Langflow imports the environment variables from your .env file, as well as any others that you set in your terminal, and then adopts their specified values.
Configure environment variables for development
The following examples show how to configure Langflow using environment variables in different development scenarios.
- .env file
- Systemd service
- VSCode tasks.json
The .env file is a text file that contains key-value pairs of environment variables.
Create or edit a .env file in the root directory of your application or Langflow environment, and then add your configuration variables to the file:
Example: .env
_29DO_NOT_TRACK=True_29LANGFLOW_AUTO_LOGIN=False_29LANGFLOW_AUTO_SAVING=True_29LANGFLOW_AUTO_SAVING_INTERVAL=1000_29LANGFLOW_BACKEND_ONLY=False_29LANGFLOW_BUNDLE_URLS=["https://github.com/user/repo/commit/hash"]_29LANGFLOW_CACHE_TYPE=async_29LANGFLOW_COMPONENTS_PATH=/path/to/components/_29LANGFLOW_CONFIG_DIR=/path/to/config/_29LANGFLOW_DATABASE_URL=postgresql://user:password@localhost:5432/langflow_29LANGFLOW_DEV=False_29LANGFLOW_FALLBACK_TO_ENV_VAR=False_29LANGFLOW_HEALTH_CHECK_MAX_RETRIES=5_29LANGFLOW_HOST=localhost_29LANGFLOW_LANGCHAIN_CACHE=InMemoryCache_29LANGFLOW_MAX_FILE_SIZE_UPLOAD=10000_29LANGFLOW_MAX_ITEMS_LENGTH=100_29LANGFLOW_MAX_TEXT_LENGTH=1000_29LANGFLOW_LOG_LEVEL=error_29LANGFLOW_OPEN_BROWSER=False_29LANGFLOW_PORT=7860_29LANGFLOW_REMOVE_API_KEYS=False_29LANGFLOW_SAVE_DB_IN_CONFIG_DIR=True_29LANGFLOW_SECRET_KEY=somesecretkey_29LANGFLOW_STORE_ENVIRONMENT_VARIABLES=True_29LANGFLOW_SUPERUSER=adminuser_29LANGFLOW_SUPERUSER_PASSWORD=adminpass_29LANGFLOW_WORKER_TIMEOUT=60000_29LANGFLOW_WORKERS=3
A systemd service configuration file configures Linux system services.
To add environment variables, create or edit a service configuration file and add an override.conf file. This file allows you to override the default environment variables for the service.
Example: override.conf
_32[Service]_32Environment="DO_NOT_TRACK=true"_32Environment="LANGFLOW_AUTO_LOGIN=false"_32Environment="LANGFLOW_AUTO_SAVING=true"_32Environment="LANGFLOW_AUTO_SAVING_INTERVAL=1000"_32Environment="LANGFLOW_BACKEND_ONLY=false"_32Environment="LANGFLOW_BUNDLE_URLS=[\"https://github.com/user/repo/commit/hash\"]"_32Environment="LANGFLOW_CACHE_TYPE=async"_32Environment="LANGFLOW_COMPONENTS_PATH=/path/to/components/"_32Environment="LANGFLOW_CONFIG_DIR=/path/to/config"_32Environment="LANGFLOW_DATABASE_URL=postgresql://user:password@localhost:5432/langflow"_32Environment="LANGFLOW_DEV=false"_32Environment="LANGFLOW_FALLBACK_TO_ENV_VAR=false"_32Environment="LANGFLOW_HEALTH_CHECK_MAX_RETRIES=5"_32Environment="LANGFLOW_HOST=localhost"_32Environment="LANGFLOW_LANGCHAIN_CACHE=InMemoryCache"_32Environment="LANGFLOW_MAX_FILE_SIZE_UPLOAD=10000"_32Environment="LANGFLOW_MAX_ITEMS_LENGTH=100"_32Environment="LANGFLOW_MAX_TEXT_LENGTH=1000"_32Environment="LANGFLOW_LOG_ENV=container_json"_32Environment="LANGFLOW_LOG_FILE=logs/langflow.log"_32Environment="LANGFLOW_LOG_LEVEL=error"_32Environment="LANGFLOW_OPEN_BROWSER=false"_32Environment="LANGFLOW_PORT=7860"_32Environment="LANGFLOW_REMOVE_API_KEYS=false"_32Environment="LANGFLOW_SAVE_DB_IN_CONFIG_DIR=true"_32Environment="LANGFLOW_SECRET_KEY=somesecretkey"_32Environment="LANGFLOW_STORE_ENVIRONMENT_VARIABLES=true"_32Environment="LANGFLOW_SUPERUSER=adminuser"_32Environment="LANGFLOW_SUPERUSER_PASSWORD=adminpass"_32Environment="LANGFLOW_WORKER_TIMEOUT=60000"_32Environment="LANGFLOW_WORKERS=3"
For more information on systemd, see the Red Hat documentation.
The tasks.json file located in .vscode/tasks.json is a configuration file for development environments using Visual Studio Code.
Create or edit the .vscode/tasks.json file in your project root.
Example: .vscode/tasks.json
_47{_47 "version": "2.0.0",_47 "options": {_47 "env": {_47 "DO_NOT_TRACK": "true",_47 "LANGFLOW_AUTO_LOGIN": "false",_47 "LANGFLOW_AUTO_SAVING": "true",_47 "LANGFLOW_AUTO_SAVING_INTERVAL": "1000",_47 "LANGFLOW_BACKEND_ONLY": "false",_47 "LANGFLOW_BUNDLE_URLS": "[\"https://github.com/user/repo/commit/hash\"]",_47 "LANGFLOW_CACHE_TYPE": "async",_47 "LANGFLOW_COMPONENTS_PATH": "D:/path/to/components/",_47 "LANGFLOW_CONFIG_DIR": "D:/path/to/config/",_47 "LANGFLOW_DATABASE_URL": "postgresql://postgres:password@localhost:5432/langflow",_47 "LANGFLOW_DEV": "false",_47 "LANGFLOW_FALLBACK_TO_ENV_VAR": "false",_47 "LANGFLOW_HEALTH_CHECK_MAX_RETRIES": "5",_47 "LANGFLOW_HOST": "localhost",_47 "LANGFLOW_LANGCHAIN_CACHE": "InMemoryCache",_47 "LANGFLOW_MAX_FILE_SIZE_UPLOAD": "10000",_47 "LANGFLOW_MAX_ITEMS_LENGTH": "100",_47 "LANGFLOW_MAX_TEXT_LENGTH": "1000",_47 "LANGFLOW_LOG_ENV": "container_csv",_47 "LANGFLOW_LOG_FILE": "langflow.log",_47 "LANGFLOW_LOG_LEVEL": "error",_47 "LANGFLOW_OPEN_BROWSER": "false",_47 "LANGFLOW_PORT": "7860",_47 "LANGFLOW_REMOVE_API_KEYS": "true",_47 "LANGFLOW_SAVE_DB_IN_CONFIG_DIR": "false",_47 "LANGFLOW_SECRET_KEY": "somesecretkey",_47 "LANGFLOW_STORE_ENVIRONMENT_VARIABLES": "true",_47 "LANGFLOW_SUPERUSER": "adminuser",_47 "LANGFLOW_SUPERUSER_PASSWORD": "adminpass",_47 "LANGFLOW_WORKER_TIMEOUT": "60000",_47 "LANGFLOW_WORKERS": "3"_47 }_47 },_47 "tasks": [_47 {_47 "label": "langflow backend",_47 "type": "shell",_47 "command": ". ./langflownightly/Scripts/activate && langflow run",_47 "isBackground": true,_47 "problemMatcher": []_47 }_47 ]_47}
To run Langflow using the above VSCode tasks.json file, in the VSCode command palette, select Tasks: Run Task > langflow backend.
Set environment variables for Langflow Desktop
Environment variables set in your terminal aren't automatically available to GUI-based applications like Langflow Desktop when you launch them from the Windows or macOS GUI.
To modify environment variables for Langflow Desktop, set environment variables in a Desktop .env file, and then restart the app.
- macOS
- Windows .env file
- Windows user environment variables
To modify the macOS .env file, do the following:
-
Create or edit
~/.langflow/data/.env. -
Add your Langflow environment variables, for example:
_10LANGFLOW_LOG_LEVEL=info_10LANGFLOW_DOCLING=true -
Save the file.
-
Restart Langflow Desktop.
To modify the Windows .env file, do the following:
-
Create or edit
%APPDATA%\com.LangflowDesktop\data\.env. -
Add your Langflow environment variables, for example:
_10LANGFLOW_LOG_LEVEL=info_10LANGFLOW_DOCLING=true -
Save the file.
-
Restart Langflow Desktop.
Windows supports two sources for Langflow Desktop environment variables: a Langflow application .env file, and Windows user environment variables.
The .env file at %APPDATA%\com.LangflowDesktop\data\.env is the recommended approach, but
Windows user variables are useful for single-sourcing API keys between Langflow and other Windows applications.
If the same variable is defined in both the Langflow application .env file and as a Windows user environment variable, the .env file takes precedence.
To modify the Windows user environment variables, do the following:
- Press Win + R, enter
sysdm.cpl, and then press Enter. - Click the Advanced tab, and then click Environment Variables.
- In User variables, click New.
- Enter the variable name, such as
OPENAI_API_KEY, and its value. - Click OK, and then restart Langflow Desktop.
Supported environment variables
The following sections provide information about specific Langflow environment variables.
Authentication and security
See API keys and authentication.
Global variables
For information about the relationship between Langflow global variables and environment variables, as well as environment variables that control handling of global variables, see Global variables.
Logs
MCP servers
See Use Langflow as an MCP server.
Monitoring and metrics
For environment variables for specific monitoring service providers, see the Langflow monitoring integration guides, such as Langfuse and Best practices for Langflow on Kubernetes.
Server
The following environment variables set base Langflow server configuration, such as where the server is hosted, required files for SSL encryption, and the deployment type (frontend and backend, backend-only, development mode).
| Variable | Format | Default | Description |
|---|---|---|---|
LANGFLOW_HOST | String | localhost | The host on which the Langflow server will run. |
LANGFLOW_PORT | Integer | 7860 | The port on which the Langflow server runs. The server automatically selects a free port if the specified port is in use. |
LANGFLOW_BACKEND_ONLY | Boolean | False | Run only the Langflow backend service (no frontend). |
LANGFLOW_DEV | Boolean | False | Whether to run Langflow in development mode (may contain bugs). |
LANGFLOW_OPEN_BROWSER | Boolean | False | Open the system web browser on startup. |
LANGFLOW_HEALTH_CHECK_MAX_RETRIES | Integer | 5 | Set the maximum number of retries for Langflow's server status health checks. |
LANGFLOW_WORKERS | Integer | 1 | Number of worker processes. |
LANGFLOW_WORKER_TIMEOUT | Integer | 300 | Worker timeout in seconds. |
LANGFLOW_SSL_CERT_FILE | String | Not set | Path to the SSL certificate file for enabling HTTPS on the Langflow web server. This is separate from database SSL connections. |
LANGFLOW_SSL_KEY_FILE | String | Not set | Path to the SSL key file for enabling HTTPS on the Langflow web server. This is separate from database SSL connections. |
LANGFLOW_DEACTIVATE_TRACING | Boolean | False | Deactivate tracing functionality. |
LANGFLOW_CELERY_ENABLED | Boolean | False | Enable Celery for distributed task processing. |
LANGFLOW_ALEMBIC_LOG_TO_STDOUT | Boolean | False | Whether to log Alembic database migration output to stdout instead of a log file. If true, Alembic logs to stdout and the default log file is ignored. |
For more information about deploying Langflow servers, see Langflow deployment overview.
Storage
For file storage environment variables, see File storage environment variables.
For database environment variables, including PostgreSQL configuration, see Memory management options.
Telemetry
See Telemetry.
Visual editor and Playground behavior
| Variable | Format | Default | Description |
|---|---|---|---|
LANGFLOW_AUTO_SAVING | Boolean | True | Whether to automatically save flows. |
LANGFLOW_AUTO_SAVING_INTERVAL | Integer | 1000 | Set the auto-save interval in milliseconds if LANGFLOW_AUTO_SAVING=True. |
LANGFLOW_BUNDLE_URLS | List[String] | [] | A list of URLs from which to load custom bundles. Supports GitHub URLs. If LANGFLOW_AUTO_LOGIN=True, flows from these bundles are loaded into the database. |
LANGFLOW_COMPONENTS_PATH | String | Not set | Path to a directory containing custom components. Typically used if you have local custom components or you are building a Docker image with custom components. |
LANGFLOW_LOAD_FLOWS_PATH | String | Not set | Path to a directory containing flow JSON files to be loaded on startup. Typically used when creating a Docker image with prepackaged flows. Requires LANGFLOW_AUTO_LOGIN=True. |
LANGFLOW_CREATE_STARTER_PROJECTS | Boolean | True | Whether to create templates during initialization. If false, Langflow doesn't create templates, and LANGFLOW_UPDATE_STARTER_PROJECTS is treated as false. |
LANGFLOW_UPDATE_STARTER_PROJECTS | Boolean | True | Whether to update templates with the latest component versions when initializing after an upgrade. |
LANGFLOW_LAZY_LOAD_COMPONENTS | Boolean | False | If true, Langflow only partially loads components at startup and fully loads them on demand. This significantly reduces startup time but can cause a slight delay when a component is first used. |
LANGFLOW_EVENT_DELIVERY | String | streaming | How to deliver build events to the frontend: polling, streaming or direct. |
LANGFLOW_FRONTEND_PATH | String | ./frontend | Path to the frontend directory containing build files. For development purposes only when you need to serve specific frontend code. |
LANGFLOW_MAX_ITEMS_LENGTH | Integer | 100 | Maximum number of items to store and display in the visual editor. Lists longer than this will be truncated when displayed in the visual editor. Doesn't affect outputs or data passed between components. |
LANGFLOW_MAX_TEXT_LENGTH | Integer | 1000 | Maximum number of characters to store and display in the visual editor. Responses longer than this will be truncated when displayed in the visual editor. Doesn't truncate outputs or responses passed between components. |
LANGFLOW_MAX_TRANSACTIONS_TO_KEEP | Integer | 3000 | Maximum number of flow transaction events to keep in the database. |
LANGFLOW_MAX_VERTEX_BUILDS_TO_KEEP | Integer | 3000 | Maximum number of vertex builds to keep in the database. Relates to Playground functionality. |
LANGFLOW_MAX_VERTEX_BUILDS_PER_VERTEX | Integer | 2 | Maximum number of builds to keep per vertex. Older builds are deleted. Relates to Playground functionality. |
LANGFLOW_PUBLIC_FLOW_CLEANUP_INTERVAL | Integer | 3600 | The interval in seconds at which data for shared Playground flows are cleaned up. Default: 3600 seconds (1 hour). Minimum: 600 seconds (10 minutes). |
LANGFLOW_PUBLIC_FLOW_EXPIRATION | Integer | 86400 | The time in seconds after which a shared Playground flow is considered expired and eligible for cleanup. Default: 86400 seconds (24 hours). Minimum: 600 seconds (10 minutes). |