Environment Variables
reflex.config.EnvironmentVariablesReflex 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 the environment variables that are not config parameters. Environment variables that override rx.Config parameters (e.g. REFLEX_FRONTEND_PORT) are listed in the config reference.
Environment Variables
| Name | Type | Default | Description |
|---|---|---|---|
ALEMBIC_CONFIG | Path | alembic.ini | Path to the alembic config file |
Path to the alembic config file | |||
ALEMBIC_INCLUDE_SCHEMAS | bool | False | Include schemas in alembic migrations. |
Include schemas in alembic migrations. | |||
APP_HARNESS_DRIVER | str | Chrome | Which app harness driver to use. |
Which app harness driver to use. | |||
APP_HARNESS_DRIVER_ARGS | str | | Arguments to pass to the app harness driver. |
Arguments to pass to the app harness driver. | |||
APP_HARNESS_HEADLESS | bool | False | Whether to run app harness tests in headless mode. |
Whether to run app harness tests in headless mode. | |||
NPM_CONFIG_REGISTRY | str | None | None | The npm registry to use. |
The npm registry to use. | |||
REFLEX_ADD_ALL_ROUTES_ENDPOINT | bool | False | Used by flexgen to enumerate the pages. |
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. |
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. |
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. |
Whether to run the backend only. Exclusive with REFLEX_FRONTEND_ONLY. | |||
REFLEX_BACKEND_PORT | int | None | None | The port to run the backend on. |
The port to run the backend on. | |||
REFLEX_CHECK_LATEST_VERSION | bool | True | Whether to check for outdated package versions. |
Whether to check for outdated package versions. | |||
REFLEX_DIR | Path | /home/runner/.local/share/reflex | The directory to store reflex dependencies. |
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. |
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. |
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 |
This env var stores the execution mode of the app | |||
REFLEX_EXTRA_PLUGINS | list | [] | Extra plugins to append to the config's plugins list. |
Extra plugins to append to the config's plugins list. | |||
REFLEX_FRONTEND_ONLY | bool | False | Whether to run the frontend only. Exclusive with REFLEX_BACKEND_ONLY. |
Whether to run the frontend only. Exclusive with REFLEX_BACKEND_ONLY. | |||
REFLEX_FRONTEND_PORT | int | None | None | The port to run the frontend on. |
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. |
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. |
Additional paths to include in the hot reload. Separated by a colon. | |||
REFLEX_HOT_RELOAD_OVERRIDE_PATHS | list | [] | Paths to override in the hot reload. Takes precedence over include and exclude paths. Separated by a colon. |
Paths to override in the hot reload. Takes precedence over include and exclude paths. 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. |
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. |
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. |
The path to the reflex log file. If not set, the log file will be stored in the reflex user directory. | |||
REFLEX_NO_AUTOPREFIXER | bool | False | Read by the generated postcss.config.js to skip autoprefixer in preview mode. |
Read by the generated postcss.config.js to skip autoprefixer in preview mode. | |||
REFLEX_OPLOCK_ENABLED | bool | False | Whether to opportunistically hold the redis lock to allow fast in-memory access while uncontended. |
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). |
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. |
In which performance mode to run the app. | |||
REFLEX_PERSIST_WEB_DIR | bool | False | Whether to skip purging the web directory in dev mode. |
Whether to skip purging the web directory in dev mode. | |||
REFLEX_SOCKET_INTERVAL | int | 25 | The interval to send a ping to the websocket server in seconds. |
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. |
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. |
The timeout to wait for a pong from the websocket server in seconds. | |||
REFLEX_SSR | bool | True | Whether to enable SSR for the frontend. |
Whether to enable SSR for the frontend. | |||
REFLEX_STATES_WORKDIR | Path | .states | The working directory for the states directory. |
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.) |
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. |
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. |
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. |
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. |
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. |
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. |
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. |
Whether to use the system installed bun. If set to false, bun will be bundled with the app. | |||
REFLEX_WEB_WORKDIR | Path | .web | The working directory for the frontend directory. |
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. |
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. |
The maximum overflow size of the database connection pool. | |||
SQLALCHEMY_POOL_PRE_PING | bool | True | Whether to check db connections before using them. |
Whether to check db connections before using them. | |||
SQLALCHEMY_POOL_RECYCLE | int | -1 | Recycle connections after this many seconds. |
Recycle connections after this many seconds. | |||
SQLALCHEMY_POOL_SIZE | int | 5 | The size of the database connection pool. |
The size of the database connection pool. | |||
SQLALCHEMY_POOL_TIMEOUT | int | 30 | The timeout for acquiring a connection from the pool. |
The timeout for acquiring a connection from the pool. | |||
SSL_NO_VERIFY | bool | False | Disable SSL verification for HTTPX requests. |
Disable SSL verification for HTTPX requests. | |||
VITE_EXPERIMENTAL_HMR | bool | False | Whether to enable Rolldown's experimental HMR. |
Whether to enable Rolldown's experimental HMR. | |||
VITE_FORCE_FULL_RELOAD | bool | False | Whether to force a full reload on changes. |
Whether to force a full reload on changes. | |||
VITE_HMR | bool | True | Whether to enable hot module replacement |
Whether to enable hot module replacement | |||
VITE_MINIFY | bool | True | Whether to minify the frontend build output. Disabled by preview mode for readable bundles. |
Whether to minify the frontend build output. Disabled by preview mode for readable bundles. | |||
VITE_SOURCEMAP | Literal | False | Whether to generate sourcemaps for the frontend. |
Whether to generate sourcemaps for the frontend. | |||