> For AI agents: the complete documentation index is at [llms.txt](https://reflex.dev/docs/llms.txt). Markdown versions are available by appending `.md` or sending `Accept: text/markdown`.

# Environment Variables

`reflex.config.EnvironmentVariables`

Reflex provides a number of environment variables that can be used to configure the behavior of your application.
These environment variables can be set in your shell environment or in a `.env` file.

This page documents all available environment variables in Reflex.

## Environment Variables

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `ALEMBIC_CONFIG` | `Path` | `alembic.ini` | Path to the alembic config file |
| `ALEMBIC_INCLUDE_SCHEMAS` | `bool` | `False` | Include schemas in alembic migrations. |
| `APP_HARNESS_DRIVER` | `str` | `Chrome` | Which app harness driver to use. |
| `APP_HARNESS_DRIVER_ARGS` | `str` | `` | Arguments to pass to the app harness driver. |
| `APP_HARNESS_HEADLESS` | `bool` | `False` | Whether to run app harness tests in headless mode. |
| `NPM_CONFIG_REGISTRY` | `str \| None` | `None` | The npm registry to use. |
| `REFLEX_ADD_ALL_ROUTES_ENDPOINT` | `bool` | `False` | Used by flexgen to enumerate the pages. |
| `REFLEX_AUTO_RELOAD_COOLDOWN_TIME_MS` | `int` | `10000` | How long to wait between automatic reload on frontend error to avoid reload loops. |
| `REFLEX_BACKEND_COLD_START_TIMEOUT` | `int` | `10` | The timeout for the backend to do a cold start in seconds. |
| `REFLEX_BACKEND_ONLY` | `bool` | `False` | Whether to run the backend only. Exclusive with REFLEX_FRONTEND_ONLY. |
| `REFLEX_BACKEND_PORT` | `int \| None` | `None` | The port to run the backend on. |
| `REFLEX_CHECK_LATEST_VERSION` | `bool` | `True` | Whether to check for outdated package versions. |
| `__REFLEX_COMPILE_CONTEXT` | `CompileContext` | `CompileContext.UNDEFINED` | Indicate the current command that was invoked in the reflex CLI. |
| `REFLEX_DIR` | `Path` | `/home/runner/.local/share/reflex` | The directory to store reflex dependencies. |
| `REFLEX_DOES_BACKEND_COLD_START` | `bool` | `False` | Enables different behavior for when the backend would do a cold start if it was inactive. |
| `REFLEX_ENABLE_FULL_LOGGING` | `bool` | `False` | Enable full logging of debug messages to reflex user directory. |
| `REFLEX_ENV_MODE` | `Env` | `Env.DEV` | This env var stores the execution mode of the app |
| `REFLEX_FRONTEND_ONLY` | `bool` | `False` | Whether to run the frontend only. Exclusive with REFLEX_BACKEND_ONLY. |
| `REFLEX_FRONTEND_PORT` | `int \| None` | `None` | The port to run the frontend on. |
| `REFLEX_HOT_RELOAD_EXCLUDE_PATHS` | `list` | `[]` | Paths to exclude from the hot reload. Takes precedence over include paths. Separated by a colon. |
| `REFLEX_HOT_RELOAD_INCLUDE_PATHS` | `list` | `[]` | Additional paths to include in the hot reload. Separated by a colon. |
| `REFLEX_HTTP_CLIENT_BIND_ADDRESS` | `str \| None` | `None` | The address to bind the HTTP client to. You can set this to "::" to enable IPv6. |
| `REFLEX_IGNORE_REDIS_CONFIG_ERROR` | `bool` | `False` | Whether to ignore the redis config error. Some redis servers only allow out-of-band configuration. |
| `REFLEX_LOG_FILE` | `pathlib._local.Path \| None` | `None` | The path to the reflex log file. If not set, the log file will be stored in the reflex user directory. |
| `__REFLEX_MOUNT_FRONTEND_COMPILED_APP` | `bool` | `False` | Whether to mount the compiled frontend app in the backend server in production. |
| `REFLEX_OPLOCK_ENABLED` | `bool` | `False` | Whether to opportunistically hold the redis lock to allow fast in-memory access while uncontended. |
| `REFLEX_OPLOCK_HOLD_TIME_MS` | `int` | `0` | How long to opportunistically hold the redis lock in milliseconds (must be less than the token expiration). |
| `REFLEX_PERF_MODE` | `PerformanceMode` | `PerformanceMode.WARN` | In which performance mode to run the app. |
| `REFLEX_PERSIST_WEB_DIR` | `bool` | `False` | Whether to skip purging the web directory in dev mode. |
| `__REFLEX_SKIP_COMPILE` | `bool` | `False` | If this env var is set to "yes", App.compile will be a no-op |
| `REFLEX_SOCKET_INTERVAL` | `int` | `25` | The interval to send a ping to the websocket server in seconds. |
| `REFLEX_SOCKET_MAX_HTTP_BUFFER_SIZE` | `int` | `1000000` | Maximum size of the message in the websocket server in bytes. |
| `REFLEX_SOCKET_TIMEOUT` | `int` | `120` | The timeout to wait for a pong from the websocket server in seconds. |
| `REFLEX_SSR` | `bool` | `True` | Whether to enable SSR for the frontend. |
| `REFLEX_STATES_WORKDIR` | `Path` | `.states` | The working directory for the states directory. |
| `REFLEX_STATE_MANAGER_DISK_DEBOUNCE_SECONDS` | `float` | `2.0` | How long to delay writing updated states to disk. (Higher values mean less writes, but more chance of lost data.) |
| `REFLEX_STATE_MANAGER_REDIS_DEBUG` | `bool` | `False` | Whether to enable debug logging for the redis state manager. |
| `REFLEX_STATE_SIZE_LIMIT` | `int` | `1000` | The maximum size of the reflex state in kilobytes. |
| `REFLEX_STRICT_HOT_RELOAD` | `bool` | `False` | Whether to run Granian in a spawn process. This enables Reflex to pick up on environment variable changes between hot reloads. |
| `REFLEX_UPLOADED_FILES_DIR` | `Path` | `uploaded_files` | The directory to store uploaded files. |
| `REFLEX_USE_GRANIAN` | `bool` | `False` | Whether to use Granian for the backend. By default, the backend uses Uvicorn if available. |
| `REFLEX_USE_NPM` | `bool` | `False` | Whether to use npm over bun to install and run the frontend. |
| `REFLEX_USE_SYSTEM_BUN` | `bool` | `False` | Whether to use the system installed bun. If set to false, bun will be bundled with the app. |
| `REFLEX_USE_TURBOPACK` | `bool` | `False` | Whether to use the turbopack bundler. |
| `REFLEX_WEB_WORKDIR` | `Path` | `.web` | The working directory for the frontend directory. |
| `SQLALCHEMY_ECHO` | `bool` | `False` | Whether to print the SQL queries if the log level is INFO or lower. |
| `SQLALCHEMY_MAX_OVERFLOW` | `int` | `10` | The maximum overflow size of the database connection pool. |
| `SQLALCHEMY_POOL_PRE_PING` | `bool` | `True` | Whether to check db connections before using them. |
| `SQLALCHEMY_POOL_RECYCLE` | `int` | `-1` | Recycle connections after this many seconds. |
| `SQLALCHEMY_POOL_SIZE` | `int` | `5` | The size of the database connection pool. |
| `SQLALCHEMY_POOL_TIMEOUT` | `int` | `30` | The timeout for acquiring a connection from the pool. |
| `SSL_NO_VERIFY` | `bool` | `False` | Disable SSL verification for HTTPX requests. |
| `VITE_EXPERIMENTAL_HMR` | `bool` | `False` | Whether to enable Rolldown's experimental HMR. |
| `VITE_FORCE_FULL_RELOAD` | `bool` | `False` | Whether to force a full reload on changes. |
| `VITE_HMR` | `bool` | `True` | Whether to enable hot module replacement |
| `VITE_SOURCEMAP` | `Literal` | `False` | Whether to generate sourcemaps for the frontend. |
