This page provides an overview of how Langflow's configuration system works: where settings are defined, in what order sources are evaluated, and which backend services each configuration domain affects. Details for each area are covered in the child pages:
Settings Pydantic model and its fields, see Backend Settings Service.Langflow resolves configuration from multiple sources. When the same setting is available in more than one source, the source with the highest precedence wins.
Precedence order (highest to lowest):
langflow run (defined in src/backend/base/langflow/__main__.py)LANGFLOW_HOST, LANGFLOW_AUTO_LOGIN).env file loaded via python-dotenv (defaults to .env in the working directory)load_settings_from_yaml (from lfx.services.settings.base)SettingsThe CLI run command accepts --env-file to point at a custom .env file. The Makefile defaults this to .env Makefile19
Configuration Loading Diagram
Sources: src/backend/base/langflow/services/settings/base.py src/backend/base/langflow/__main__.py183-250 Makefile16-25
The central configuration object is the Settings class, defined in lfx.services.settings.base and re-exported by langflow.services.settings.base src/backend/base/langflow/services/settings/base.py1-16
Settings is a pydantic-settings BaseSettings subclass. CustomSource is the custom settings source that implements the multi-source merge. The model is instantiated once during application startup in initialize_settings_service() src/backend/base/langflow/services/utils.py and wrapped by SettingsService, which is accessible anywhere via the get_settings_service() dependency src/backend/base/langflow/services/utils.py19
Authentication-specific settings are separated into auth_settings on the service. This sub-object holds fields like AUTO_LOGIN and SECRET_KEY.
The following table summarizes the major configuration areas, the corresponding Settings fields or sub-objects, and the service that consumes them.
| Domain | Representative env var | Settings field | Consumer |
|---|---|---|---|
| Server bind | LANGFLOW_HOST, LANGFLOW_PORT | CLI flags → uvicorn | __main__.py / uvicorn |
| Authentication | LANGFLOW_AUTO_LOGIN, LANGFLOW_SECRET_KEY | auth_settings.AUTO_LOGIN | AuthService |
| Database | LANGFLOW_DATABASE_URL | settings.database_url | DatabaseService |
| DB connection pool | LANGFLOW_DB_POOL_SIZE | settings.db_connection_settings | DatabaseService |
| Database migrations | LANGFLOW_ALEMBIC_LOG_FILE | settings.alembic_log_file | DatabaseService |
| CORS | LANGFLOW_CORS_ORIGINS | settings.cors_origins | main.py / FastAPI middleware |
| Component discovery | LANGFLOW_COMPONENTS_PATH | settings.components_path | Component loader |
| File storage backend | LANGFLOW_STORAGE_TYPE | settings.storage_type | StorageService |
| Agentic mode | LANGFLOW_AGENTIC_EXPERIENCE | settings.agentic_experience | main.py lifespan |
Sources: src/backend/base/langflow/services/database/service.py42-90 src/backend/base/langflow/main.py135-231
Settings-to-Services Diagram
Sources: src/backend/base/langflow/main.py147-231 src/backend/base/langflow/services/database/service.py42-90 src/backend/base/langflow/services/utils.py
During startup, get_lifespan() in langflow.main calls initialize_settings_service() before any other service is started src/backend/base/langflow/main.py147-172 This makes get_settings_service() available globally for all subsequent service initialization calls in initialize_services().
The langflow run CLI command (entry point defined in pyproject.toml as langflow.langflow_launcher:main) accepts the following server-level flags that bypass the Settings model entirely and are passed directly to uvicorn or gunicorn:
| CLI flag | Default | Description |
|---|---|---|
--host | 0.0.0.0 | Interface to bind |
--port | 7860 | TCP port |
--workers | 1 | Number of worker processes |
--log-level | debug (dev) | Logging verbosity |
--env-file | .env | Path to .env file |
--frontend-path | bundled | Path to pre-built frontend assets |
--no-open-browser | — | Suppress auto-open on start |
Sources: src/backend/base/langflow/__main__.py183-250 Makefile236-254 pyproject.toml155-156
The React frontend discovers the backend API base URL by examining the page's origin at startup. In development mode, src/frontend/package.json sets a Vite dev-server proxy to http://localhost:7860 src/frontend/package.json139 so API calls made against /api/* are forwarded to the backend without CORS complications.
In production, the frontend is served as static files by FastAPI's StaticFiles mount, so the base URL is the same origin as the frontend itself. The frontend fetches additional runtime configuration (such as feature flags and auth mode) from backend API endpoints during initialization.
For full details on the frontend constants file and startup config fetch, see Frontend Configuration.
| File | Purpose |
|---|---|
.env | Primary local config overrides; loaded by --env-file |
pyproject.toml | Package metadata and langflow entry point |
src/backend/base/langflow/services/settings/base.py | Re-export of Settings from lfx |
src/lfx/src/lfx/services/settings/base.py | Canonical Settings Pydantic model |
src/frontend/package.json | Frontend dev-server proxy config |
Makefile | Developer-facing defaults for host/port/env |
Sources: src/backend/base/langflow/services/settings/base.py src/frontend/package.json139 Makefile16-25 pyproject.toml155-156
Refresh this wiki
This wiki was recently refreshed. Please wait 3 days to refresh again.