Environment variables
Langflow lets you configure a number of settings using environment variables.
Configure environment variables
Langflow recognizes supported environment variables from the following sources:
- Environment variables that you've set in your terminal.
- Environment variables that you've imported from a
.env
file using the--env-file
option in the Langflow CLI.
You can choose to use one source exclusively, or use both sources together.
If you choose to use both sources together, be aware that environment variables imported from a .env
file take precedence over those set in your terminal.
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
-
Create a
.env
file and open it in your preferred editor. -
Add your environment variables to the file:
_28DO_NOT_TRACK=true_28LANGFLOW_AUTO_LOGIN=false_28LANGFLOW_AUTO_SAVING=true_28LANGFLOW_AUTO_SAVING_INTERVAL=1000_28LANGFLOW_BACKEND_ONLY=false_28LANGFLOW_BUNDLE_URLS=["https://github.com/user/repo/commit/hash"]_28LANGFLOW_CACHE_TYPE=async_28LANGFLOW_COMPONENTS_PATH=/path/to/components/_28LANGFLOW_CONFIG_DIR=/path/to/config/_28LANGFLOW_DATABASE_URL=postgresql://user:password@localhost:5432/langflow_28LANGFLOW_DEV=false_28LANGFLOW_FALLBACK_TO_ENV_VAR=false_28LANGFLOW_HEALTH_CHECK_MAX_RETRIES=5_28LANGFLOW_HOST=127.0.0.1_28LANGFLOW_LANGCHAIN_CACHE=InMemoryCache_28LANGFLOW_MAX_FILE_SIZE_UPLOAD=10000_28LANGFLOW_LOG_LEVEL=error_28LANGFLOW_OPEN_BROWSER=false_28LANGFLOW_PORT=7860_28LANGFLOW_REMOVE_API_KEYS=false_28LANGFLOW_SAVE_DB_IN_CONFIG_DIR=true_28LANGFLOW_SECRET_KEY=somesecretkey_28LANGFLOW_STORE=true_28LANGFLOW_STORE_ENVIRONMENT_VARIABLES=true_28LANGFLOW_SUPERUSER=adminuser_28LANGFLOW_SUPERUSER_PASSWORD=adminpass_28LANGFLOW_WORKER_TIMEOUT=60000_28LANGFLOW_WORKERS=3tipThe Langflow project includes a
.env.example
file to help you get started. You can copy the contents of this file into your own.env
file and replace the example values with your own preferred settings. -
Save and close the file.
-
Start Langflow using the
--env-file
option to define the path to your.env
file:- Local
- Docker
_10python -m langflow run --env-file .env_10docker run -it --rm \_10-p 7860:7860 \_10--env-file .env \_10langflowai/langflow:latest
On startup, Langflow imports the environment variables from your .env
file, as well as any that you set in your terminal, and adopts their specified values.
Precedence
Environment variables defined in the .env file take precedence over those set in your terminal.
That means, if you happen to set the same environment variable in both your terminal and your .env
file, Langflow adopts the value from the the .env
file.
Langflow CLI options override the value of corresponding environment variables defined in the .env
file as well as any environment variables set in your terminal.
Supported environment variables
The following table lists the environment variables supported by Langflow.
Variable | Format | Default | Description |
---|---|---|---|
DO_NOT_TRACK | Boolean | false | If this option is enabled, Langflow does not track telemetry. |
LANGFLOW_AUTO_LOGIN | Boolean | true | Enable automatic login for Langflow. Set to false to disable automatic login and require the login form to log into the Langflow UI. Setting to false requires LANGFLOW_SUPERUSER and LANGFLOW_SUPERUSER_PASSWORD to be set. |
LANGFLOW_AUTO_SAVING | Boolean | true | Enable flow auto-saving. See --auto-saving option. |
LANGFLOW_AUTO_SAVING_INTERVAL | Integer | 1000 | Set the interval for flow auto-saving in milliseconds. See --auto-saving-interval option. |
LANGFLOW_BACKEND_ONLY | Boolean | false | Only run Langflow's backend server (no frontend). See --backend-only option. |
LANGFLOW_BUNDLE_URLS | List[String] | [] | A list of URLs from which to load component bundles and flows. Supports GitHub URLs. If LANGFLOW_AUTO_LOGIN is enabled, flows from these bundles are loaded into the database. |
LANGFLOW_CACHE_TYPE | async redis memory disk critical | async | Set the cache type for Langflow. If you set the type to redis , then you must also set the following environment variables: LANGFLOW_REDIS_HOST, LANGFLOW_REDIS_PORT, LANGFLOW_REDIS_DB, and LANGFLOW_REDIS_CACHE_EXPIRE. |
LANGFLOW_COMPONENTS_PATH | String | langflow/components | Path to the directory containing custom components. See --components-path option. |
LANGFLOW_CONFIG_DIR | String | See description | Set the Langflow configuration directory where files, logs, and the Langflow database are stored. Defaults: Linux/WSL: ~/.cache/langflow/ macOS: /Users/<username>/Library/Caches/langflow/ Windows: %LOCALAPPDATA%\langflow\langflow\Cache |
LANGFLOW_DATABASE_URL | String | Not set | Set the database URL for Langflow. If not provided, Langflow uses a SQLite database. |
LANGFLOW_DATABASE_CONNECTION_RETRY | Boolean | false | If True, Langflow tries to connect to the database again if it fails. |
LANGFLOW_DB_POOL_SIZE | Integer | 10 | DEPRECATED: Use LANGFLOW_DB_CONNECTION_SETTINGS instead. The number of connections to keep open in the connection pool. |
LANGFLOW_DB_MAX_OVERFLOW | Integer | 20 | DEPRECATED: Use LANGFLOW_DB_CONNECTION_SETTINGS instead. The number of connections to allow that can be opened beyond the pool size. |
LANGFLOW_DB_CONNECT_TIMEOUT | Integer | 20 | The number of seconds to wait before giving up on a lock to be released or establishing a connection to the database. |
LANGFLOW_DB_CONNECTION_SETTINGS | JSON | Not set | A JSON dictionary to centralize database connection parameters. Example: {"pool_size": 10, "max_overflow": 20} |
LANGFLOW_DEV | Boolean | false | Run Langflow in development mode (may contain bugs). See --dev option. |
LANGFLOW_ENABLE_LOG_RETRIEVAL | Boolean | false | Enable log retrieval functionality. |
LANGFLOW_FALLBACK_TO_ENV_VAR | Boolean | true | If enabled, global variables set in the Langflow UI fall back to an environment variable with the same name when Langflow fails to retrieve the variable value. |
LANGFLOW_FRONTEND_PATH | String | ./frontend | Path to the frontend directory containing build files. This is for development purposes only. See --frontend-path option. |
LANGFLOW_HEALTH_CHECK_MAX_RETRIES | Integer | 5 | Set the maximum number of retries for the health check. See --health-check-max-retries option. |
LANGFLOW_HOST | String | 127.0.0.1 | The host on which the Langflow server will run. See --host option. |
LANGFLOW_LANGCHAIN_CACHE | InMemoryCache SQLiteCache | InMemoryCache | Type of cache to use. See --cache option. |
LANGFLOW_LOG_LEVEL | DEBUG INFO WARNING ERROR CRITICAL | INFO | Set the logging level for Langflow. |
LANGFLOW_LOG_FILE | String | Not set | Path to the log file. If this option is not set, logs are written to stdout. |
LANGFLOW_LOG_RETRIEVER_BUFFER_SIZE | Integer | 10000 | Set the buffer size for log retrieval. Only used if LANGFLOW_ENABLE_LOG_RETRIEVAL is enabled. |
LANGFLOW_MAX_FILE_SIZE_UPLOAD | Integer | 100 | Set the maximum file size for the upload in megabytes. See --max-file-size-upload option. |
LANGFLOW_MCP_SERVER_ENABLED | Boolean | true | If this option is set to False, Langflow does not enable the MCP server. |
LANGFLOW_MCP_SERVER_ENABLE_PROGRESS_NOTIFICATIONS | Boolean | false | If this option is set to True, Langflow sends progress notifications in the MCP server. |
LANGFLOW_NEW_USER_IS_ACTIVE | Boolean | false | When enabled, new users are automatically activated and can log in without requiring explicit activation by the superuser. |
LANGFLOW_OPEN_BROWSER | Boolean | false | Open the system web browser on startup. See --open-browser option. |
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. See --port option. |
LANGFLOW_PROMETHEUS_ENABLED | Boolean | false | Expose Prometheus metrics. |
LANGFLOW_PROMETHEUS_PORT | Integer | 9090 | Set the port on which Langflow exposes Prometheus metrics. |
LANGFLOW_REDIS_CACHE_EXPIRE | Integer | 3600 | See LANGFLOW_CACHE_TYPE. |
LANGFLOW_REDIS_DB | Integer | 0 | See LANGFLOW_CACHE_TYPE. |
LANGFLOW_REDIS_HOST | String | localhost | See LANGFLOW_CACHE_TYPE. |
LANGFLOW_REDIS_PORT | String | 6379 | See LANGFLOW_CACHE_TYPE. |
LANGFLOW_REDIS_PASSWORD | String | Not set | Password for Redis authentication when using Redis cache type. |
LANGFLOW_REMOVE_API_KEYS | Boolean | false | Remove API keys from the projects saved in the database. See --remove-api-keys option. |
LANGFLOW_SAVE_DB_IN_CONFIG_DIR | Boolean | false | Save the Langflow database in LANGFLOW_CONFIG_DIR instead of in the Langflow package directory. Note, when this variable is set to default (false ), the database isn't shared between different virtual environments and the database is deleted when you uninstall Langflow. |
LANGFLOW_SECRET_KEY | String | Auto-generated | Key used for encrypting sensitive data like API keys. If a key is not provided, a secure key is auto-generated. For production environments with multiple instances, you should explicitly set this to ensure consistent encryption across instances. |
LANGFLOW_STORE | Boolean | true | Enable the Langflow Store. See --store option. |
LANGFLOW_STORE_ENVIRONMENT_VARIABLES | Boolean | true | Store environment variables as global variables in the database. |
LANGFLOW_UPDATE_STARTER_PROJECTS | Boolean | true | If this option is enabled, Langflow updates starter projects with the latest component versions when initializing. |
LANGFLOW_SUPERUSER | String | langflow | Set the name for the superuser. Required if LANGFLOW_AUTO_LOGIN is set to false .See superuser --username option. |
LANGFLOW_SUPERUSER_PASSWORD | String | langflow | Set the password for the superuser. Required if LANGFLOW_AUTO_LOGIN is set to false .See superuser --password option. |
LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENT | String | Not set | Comma-separated list of environment variables to get from the environment and store as global variables. |
LANGFLOW_LOAD_FLOWS_PATH | String | Not set | Path to a directory containing flow JSON files to be loaded on startup. Note that this feature only works if LANGFLOW_AUTO_LOGIN is enabled. |
LANGFLOW_WORKER_TIMEOUT | Integer | 300 | Worker timeout in seconds. See --worker-timeout option. |
LANGFLOW_WORKERS | Integer | 1 | Number of worker processes. See --workers option. |
LANGFLOW_SSL_CERT_FILE | String | Not set | Path to the SSL certificate file on the local system. |
LANGFLOW_SSL_KEY_FILE | String | Not set | Path to the SSL key file on the local system. |
Configure .env, override.conf, and tasks.json files
The following examples show how to configure Langflow using environment variables in different 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 file named .env
in your project root directory and add your configuration:
_28DO_NOT_TRACK=true_28LANGFLOW_AUTO_LOGIN=false_28LANGFLOW_AUTO_SAVING=true_28LANGFLOW_AUTO_SAVING_INTERVAL=1000_28LANGFLOW_BACKEND_ONLY=false_28LANGFLOW_BUNDLE_URLS=["https://github.com/user/repo/commit/hash"]_28LANGFLOW_CACHE_TYPE=async_28LANGFLOW_COMPONENTS_PATH=/path/to/components/_28LANGFLOW_CONFIG_DIR=/path/to/config/_28LANGFLOW_DATABASE_URL=postgresql://user:password@localhost:5432/langflow_28LANGFLOW_DEV=false_28LANGFLOW_FALLBACK_TO_ENV_VAR=false_28LANGFLOW_HEALTH_CHECK_MAX_RETRIES=5_28LANGFLOW_HOST=127.0.0.1_28LANGFLOW_LANGCHAIN_CACHE=InMemoryCache_28LANGFLOW_MAX_FILE_SIZE_UPLOAD=10000_28LANGFLOW_LOG_LEVEL=error_28LANGFLOW_OPEN_BROWSER=false_28LANGFLOW_PORT=7860_28LANGFLOW_REMOVE_API_KEYS=false_28LANGFLOW_SAVE_DB_IN_CONFIG_DIR=true_28LANGFLOW_SECRET_KEY=somesecretkey_28LANGFLOW_STORE=true_28LANGFLOW_STORE_ENVIRONMENT_VARIABLES=true_28LANGFLOW_SUPERUSER=adminuser_28LANGFLOW_SUPERUSER_PASSWORD=adminpass_28LANGFLOW_WORKER_TIMEOUT=60000_28LANGFLOW_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.
_31[Service]_31Environment="DO_NOT_TRACK=true"_31Environment="LANGFLOW_AUTO_LOGIN=false"_31Environment="LANGFLOW_AUTO_SAVING=true"_31Environment="LANGFLOW_AUTO_SAVING_INTERVAL=1000"_31Environment="LANGFLOW_BACKEND_ONLY=false"_31Environment="LANGFLOW_BUNDLE_URLS=[\"https://github.com/user/repo/commit/hash\"]"_31Environment="LANGFLOW_CACHE_TYPE=async"_31Environment="LANGFLOW_COMPONENTS_PATH=/path/to/components/"_31Environment="LANGFLOW_CONFIG_DIR=/path/to/config"_31Environment="LANGFLOW_DATABASE_URL=postgresql://user:password@localhost:5432/langflow"_31Environment="LANGFLOW_DEV=false"_31Environment="LANGFLOW_FALLBACK_TO_ENV_VAR=false"_31Environment="LANGFLOW_HEALTH_CHECK_MAX_RETRIES=5"_31Environment="LANGFLOW_HOST=127.0.0.1"_31Environment="LANGFLOW_LANGCHAIN_CACHE=InMemoryCache"_31Environment="LANGFLOW_MAX_FILE_SIZE_UPLOAD=10000"_31Environment="LANGFLOW_LOG_ENV=container_json"_31Environment="LANGFLOW_LOG_FILE=logs/langflow.log"_31Environment="LANGFLOW_LOG_LEVEL=error"_31Environment="LANGFLOW_OPEN_BROWSER=false"_31Environment="LANGFLOW_PORT=7860"_31Environment="LANGFLOW_REMOVE_API_KEYS=false"_31Environment="LANGFLOW_SAVE_DB_IN_CONFIG_DIR=true"_31Environment="LANGFLOW_SECRET_KEY=somesecretkey"_31Environment="LANGFLOW_STORE=true"_31Environment="LANGFLOW_STORE_ENVIRONMENT_VARIABLES=true"_31Environment="LANGFLOW_SUPERUSER=adminuser"_31Environment="LANGFLOW_SUPERUSER_PASSWORD=adminpass"_31Environment="LANGFLOW_WORKER_TIMEOUT=60000"_31Environment="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:
_46{_46 "version": "2.0.0",_46 "options": {_46 "env": {_46 "DO_NOT_TRACK": "true",_46 "LANGFLOW_AUTO_LOGIN": "false",_46 "LANGFLOW_AUTO_SAVING": "true",_46 "LANGFLOW_AUTO_SAVING_INTERVAL": "1000",_46 "LANGFLOW_BACKEND_ONLY": "false",_46 "LANGFLOW_BUNDLE_URLS": "[\"https://github.com/user/repo/commit/hash\"]",_46 "LANGFLOW_CACHE_TYPE": "async",_46 "LANGFLOW_COMPONENTS_PATH": "D:/path/to/components/",_46 "LANGFLOW_CONFIG_DIR": "D:/path/to/config/",_46 "LANGFLOW_DATABASE_URL": "postgresql://postgres:password@localhost:5432/langflow",_46 "LANGFLOW_DEV": "false",_46 "LANGFLOW_FALLBACK_TO_ENV_VAR": "false",_46 "LANGFLOW_HEALTH_CHECK_MAX_RETRIES": "5",_46 "LANGFLOW_HOST": "localhost",_46 "LANGFLOW_LANGCHAIN_CACHE": "InMemoryCache",_46 "LANGFLOW_MAX_FILE_SIZE_UPLOAD": "10000",_46 "LANGFLOW_LOG_ENV": "container_csv",_46 "LANGFLOW_LOG_FILE": "langflow.log",_46 "LANGFLOW_LOG_LEVEL": "error",_46 "LANGFLOW_OPEN_BROWSER": "false",_46 "LANGFLOW_PORT": "7860",_46 "LANGFLOW_REMOVE_API_KEYS": "true",_46 "LANGFLOW_SAVE_DB_IN_CONFIG_DIR": "false",_46 "LANGFLOW_SECRET_KEY": "somesecretkey",_46 "LANGFLOW_STORE": "true",_46 "LANGFLOW_STORE_ENVIRONMENT_VARIABLES": "true",_46 "LANGFLOW_SUPERUSER": "adminuser",_46 "LANGFLOW_SUPERUSER_PASSWORD": "adminpass",_46 "LANGFLOW_WORKER_TIMEOUT": "60000",_46 "LANGFLOW_WORKERS": "3"_46 }_46 },_46 "tasks": [_46 {_46 "label": "langflow backend",_46 "type": "shell",_46 "command": ". ./langflownightly/Scripts/activate && langflow run",_46 "isBackground": true,_46 "problemMatcher": []_46 }_46 ]_46}
To run Langflow using the above VSCode tasks.json
file, in the VSCode command palette, select Tasks: Run Task > langflow backend.