Skip to main content

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:


_10
export VARIABLE_NAME='VALUE'

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

  1. Create a .env file and open it in your preferred editor.

  2. Add your environment variables to the file:


    _28
    DO_NOT_TRACK=true
    _28
    LANGFLOW_AUTO_LOGIN=false
    _28
    LANGFLOW_AUTO_SAVING=true
    _28
    LANGFLOW_AUTO_SAVING_INTERVAL=1000
    _28
    LANGFLOW_BACKEND_ONLY=false
    _28
    LANGFLOW_BUNDLE_URLS=["https://github.com/user/repo/commit/hash"]
    _28
    LANGFLOW_CACHE_TYPE=async
    _28
    LANGFLOW_COMPONENTS_PATH=/path/to/components/
    _28
    LANGFLOW_CONFIG_DIR=/path/to/config/
    _28
    LANGFLOW_DATABASE_URL=postgresql://user:password@localhost:5432/langflow
    _28
    LANGFLOW_DEV=false
    _28
    LANGFLOW_FALLBACK_TO_ENV_VAR=false
    _28
    LANGFLOW_HEALTH_CHECK_MAX_RETRIES=5
    _28
    LANGFLOW_HOST=127.0.0.1
    _28
    LANGFLOW_LANGCHAIN_CACHE=InMemoryCache
    _28
    LANGFLOW_MAX_FILE_SIZE_UPLOAD=10000
    _28
    LANGFLOW_LOG_LEVEL=error
    _28
    LANGFLOW_OPEN_BROWSER=false
    _28
    LANGFLOW_PORT=7860
    _28
    LANGFLOW_REMOVE_API_KEYS=false
    _28
    LANGFLOW_SAVE_DB_IN_CONFIG_DIR=true
    _28
    LANGFLOW_SECRET_KEY=somesecretkey
    _28
    LANGFLOW_STORE=true
    _28
    LANGFLOW_STORE_ENVIRONMENT_VARIABLES=true
    _28
    LANGFLOW_SUPERUSER=adminuser
    _28
    LANGFLOW_SUPERUSER_PASSWORD=adminpass
    _28
    LANGFLOW_WORKER_TIMEOUT=60000
    _28
    LANGFLOW_WORKERS=3

    tip

    The 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.

  3. Save and close the file.

  4. Start Langflow using the --env-file option to define the path to your .env file:


    _10
    python -m langflow run --env-file .env

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.

CLI precedence

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.

VariableFormatDefaultDescription
DO_NOT_TRACKBooleanfalseIf this option is enabled, Langflow does not track telemetry.
LANGFLOW_AUTO_LOGINBooleantrueEnable 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_SAVINGBooleantrueEnable flow auto-saving.
See --auto-saving option.
LANGFLOW_AUTO_SAVING_INTERVALInteger1000Set the interval for flow auto-saving in milliseconds.
See --auto-saving-interval option.
LANGFLOW_BACKEND_ONLYBooleanfalseOnly run Langflow's backend server (no frontend).
See --backend-only option.
LANGFLOW_BUNDLE_URLSList[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_TYPEasync
redis
memory
disk
critical
asyncSet 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_PATHStringlangflow/componentsPath to the directory containing custom components.
See --components-path option.
LANGFLOW_CONFIG_DIRStringSee descriptionSet 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_URLStringNot setSet the database URL for Langflow. If not provided, Langflow uses a SQLite database.
LANGFLOW_DATABASE_CONNECTION_RETRYBooleanfalseIf True, Langflow tries to connect to the database again if it fails.
LANGFLOW_DB_POOL_SIZEInteger10DEPRECATED: Use LANGFLOW_DB_CONNECTION_SETTINGS instead. The number of connections to keep open in the connection pool.
LANGFLOW_DB_MAX_OVERFLOWInteger20DEPRECATED: Use LANGFLOW_DB_CONNECTION_SETTINGS instead. The number of connections to allow that can be opened beyond the pool size.
LANGFLOW_DB_CONNECT_TIMEOUTInteger20The number of seconds to wait before giving up on a lock to be released or establishing a connection to the database.
LANGFLOW_DB_CONNECTION_SETTINGSJSONNot setA JSON dictionary to centralize database connection parameters. Example: {"pool_size": 10, "max_overflow": 20}
LANGFLOW_DEVBooleanfalseRun Langflow in development mode (may contain bugs).
See --dev option.
LANGFLOW_ENABLE_LOG_RETRIEVALBooleanfalseEnable log retrieval functionality.
LANGFLOW_FALLBACK_TO_ENV_VARBooleantrueIf 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_PATHString./frontendPath to the frontend directory containing build files. This is for development purposes only.
See --frontend-path option.
LANGFLOW_HEALTH_CHECK_MAX_RETRIESInteger5Set the maximum number of retries for the health check.
See --health-check-max-retries option.
LANGFLOW_HOSTString127.0.0.1The host on which the Langflow server will run.
See --host option.
LANGFLOW_LANGCHAIN_CACHEInMemoryCache
SQLiteCache
InMemoryCacheType of cache to use.
See --cache option.
LANGFLOW_LOG_LEVELDEBUG
INFO
WARNING
ERROR
CRITICAL
INFOSet the logging level for Langflow.
LANGFLOW_LOG_FILEStringNot setPath to the log file. If this option is not set, logs are written to stdout.
LANGFLOW_LOG_RETRIEVER_BUFFER_SIZEInteger10000Set the buffer size for log retrieval. Only used if LANGFLOW_ENABLE_LOG_RETRIEVAL is enabled.
LANGFLOW_MAX_FILE_SIZE_UPLOADInteger100Set the maximum file size for the upload in megabytes.
See --max-file-size-upload option.
LANGFLOW_MCP_SERVER_ENABLEDBooleantrueIf this option is set to False, Langflow does not enable the MCP server.
LANGFLOW_MCP_SERVER_ENABLE_PROGRESS_NOTIFICATIONSBooleanfalseIf this option is set to True, Langflow sends progress notifications in the MCP server.
LANGFLOW_NEW_USER_IS_ACTIVEBooleanfalseWhen enabled, new users are automatically activated and can log in without requiring explicit activation by the superuser.
LANGFLOW_OPEN_BROWSERBooleanfalseOpen the system web browser on startup.
See --open-browser option.
LANGFLOW_PORTInteger7860The 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_ENABLEDBooleanfalseExpose Prometheus metrics.
LANGFLOW_PROMETHEUS_PORTInteger9090Set the port on which Langflow exposes Prometheus metrics.
LANGFLOW_REDIS_CACHE_EXPIREInteger3600See LANGFLOW_CACHE_TYPE.
LANGFLOW_REDIS_DBInteger0See LANGFLOW_CACHE_TYPE.
LANGFLOW_REDIS_HOSTStringlocalhostSee LANGFLOW_CACHE_TYPE.
LANGFLOW_REDIS_PORTString6379See LANGFLOW_CACHE_TYPE.
LANGFLOW_REDIS_PASSWORDStringNot setPassword for Redis authentication when using Redis cache type.
LANGFLOW_REMOVE_API_KEYSBooleanfalseRemove API keys from the projects saved in the database.
See --remove-api-keys option.
LANGFLOW_SAVE_DB_IN_CONFIG_DIRBooleanfalseSave 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_KEYStringAuto-generatedKey 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_STOREBooleantrueEnable the Langflow Store.
See --store option.
LANGFLOW_STORE_ENVIRONMENT_VARIABLESBooleantrueStore environment variables as global variables in the database.
LANGFLOW_UPDATE_STARTER_PROJECTSBooleantrueIf this option is enabled, Langflow updates starter projects with the latest component versions when initializing.
LANGFLOW_SUPERUSERStringlangflowSet the name for the superuser. Required if LANGFLOW_AUTO_LOGIN is set to false.
See superuser --username option.
LANGFLOW_SUPERUSER_PASSWORDStringlangflowSet the password for the superuser. Required if LANGFLOW_AUTO_LOGIN is set to false.
See superuser --password option.
LANGFLOW_VARIABLES_TO_GET_FROM_ENVIRONMENTStringNot setComma-separated list of environment variables to get from the environment and store as global variables.
LANGFLOW_LOAD_FLOWS_PATHStringNot setPath 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_TIMEOUTInteger300Worker timeout in seconds.
See --worker-timeout option.
LANGFLOW_WORKERSInteger1Number of worker processes.
See --workers option.
LANGFLOW_SSL_CERT_FILEStringNot setPath to the SSL certificate file on the local system.
LANGFLOW_SSL_KEY_FILEStringNot setPath 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.

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:


_28
DO_NOT_TRACK=true
_28
LANGFLOW_AUTO_LOGIN=false
_28
LANGFLOW_AUTO_SAVING=true
_28
LANGFLOW_AUTO_SAVING_INTERVAL=1000
_28
LANGFLOW_BACKEND_ONLY=false
_28
LANGFLOW_BUNDLE_URLS=["https://github.com/user/repo/commit/hash"]
_28
LANGFLOW_CACHE_TYPE=async
_28
LANGFLOW_COMPONENTS_PATH=/path/to/components/
_28
LANGFLOW_CONFIG_DIR=/path/to/config/
_28
LANGFLOW_DATABASE_URL=postgresql://user:password@localhost:5432/langflow
_28
LANGFLOW_DEV=false
_28
LANGFLOW_FALLBACK_TO_ENV_VAR=false
_28
LANGFLOW_HEALTH_CHECK_MAX_RETRIES=5
_28
LANGFLOW_HOST=127.0.0.1
_28
LANGFLOW_LANGCHAIN_CACHE=InMemoryCache
_28
LANGFLOW_MAX_FILE_SIZE_UPLOAD=10000
_28
LANGFLOW_LOG_LEVEL=error
_28
LANGFLOW_OPEN_BROWSER=false
_28
LANGFLOW_PORT=7860
_28
LANGFLOW_REMOVE_API_KEYS=false
_28
LANGFLOW_SAVE_DB_IN_CONFIG_DIR=true
_28
LANGFLOW_SECRET_KEY=somesecretkey
_28
LANGFLOW_STORE=true
_28
LANGFLOW_STORE_ENVIRONMENT_VARIABLES=true
_28
LANGFLOW_SUPERUSER=adminuser
_28
LANGFLOW_SUPERUSER_PASSWORD=adminpass
_28
LANGFLOW_WORKER_TIMEOUT=60000
_28
LANGFLOW_WORKERS=3

Search