Environment Variables
reflex_base.environment.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 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.
Variables
ALEMBIC_CONFIG
PathDefault: alembic.ini
Path to the alembic config file
ALEMBIC_INCLUDE_SCHEMAS
boolDefault: False
Include schemas in alembic migrations.
APP_HARNESS_DRIVER
strDefault: Chrome
Which app harness driver to use.
APP_HARNESS_DRIVER_ARGS
strDefault:
Arguments to pass to the app harness driver.
APP_HARNESS_HEADLESS
boolDefault: False
Whether to run app harness tests in headless mode.
NPM_CONFIG_REGISTRY
str | NoneDefault: None
The npm registry to use.
REFLEX_ADD_ALL_ROUTES_ENDPOINT
boolDefault: False
Used by flexgen to enumerate the pages.
REFLEX_AUTO_RELOAD_COOLDOWN_TIME_MS
intDefault: 10000
How long to wait between automatic reload on frontend error to avoid reload loops.
REFLEX_BACKEND_COLD_START_TIMEOUT
intDefault: 10
The timeout for the backend to do a cold start in seconds.
REFLEX_BACKEND_ONLY
boolDefault: False
Whether to run the backend only. Exclusive with REFLEX_FRONTEND_ONLY.
REFLEX_BACKEND_PORT
int | NoneDefault: None
The port to run the backend on.
REFLEX_CHECK_LATEST_VERSION
boolDefault: True
Whether to check for outdated package versions.
REFLEX_DEV_PROD_REACT
boolDefault: False
Serve React's production build under the Vite dev server (experimental).
REFLEX_DIR
PathDefault: /home/runner/.local/share/reflex
The directory to store reflex dependencies.
REFLEX_DOES_BACKEND_COLD_START
boolDefault: False
Enables different behavior for when the backend would do a cold start if it was inactive.
REFLEX_ENABLE_FULL_LOGGING
boolDefault: False
Enable full logging of debug messages to reflex user directory.
REFLEX_ENV_MODE
EnvDefault: Env.DEV
This env var stores the execution mode of the app
REFLEX_EXTRA_PLUGINS
listDefault: []
Extra plugins to append to the config's plugins list.
REFLEX_FRONTEND_ONLY
boolDefault: False
Whether to run the frontend only. Exclusive with REFLEX_BACKEND_ONLY.
REFLEX_FRONTEND_PORT
int | NoneDefault: None
The port to run the frontend on.
REFLEX_HOT_RELOAD_EXCLUDE_PATHS
listDefault: []
Paths to exclude from the hot reload. Takes precedence over include paths. Separated by a colon.
REFLEX_HOT_RELOAD_INCLUDE_PATHS
listDefault: []
Additional paths to include in the hot reload. Separated by a colon.
REFLEX_HOT_RELOAD_OVERRIDE_PATHS
listDefault: []
Paths to override in the hot reload. Takes precedence over include and exclude paths. Separated by a colon.
REFLEX_HTTP_CLIENT_BIND_ADDRESS
str | NoneDefault: None
The address to bind the HTTP client to. You can set this to "::" to enable IPv6.
REFLEX_IGNORE_REDIS_CONFIG_ERROR
boolDefault: False
Whether to ignore the redis config error. Some redis servers only allow out-of-band configuration.
REFLEX_LOG_FILE
pathlib._local.Path | NoneDefault: None
The path to the reflex log file. If not set, the log file will be stored in the reflex user directory.
REFLEX_LOG_JSON
boolDefault: False
Emit logs as machine-readable JSON records instead of rich console output.
REFLEX_NO_AUTOPREFIXER
boolDefault: False
Read by the generated postcss.config.js to skip autoprefixer in preview mode.
REFLEX_OPLOCK_ENABLED
boolDefault: False
Whether to opportunistically hold the redis lock to allow fast in-memory access while uncontended.
REFLEX_OPLOCK_HOLD_TIME_MS
intDefault: 0
How long to opportunistically hold the redis lock in milliseconds (must be less than the token expiration).
REFLEX_PERF_MODE
PerformanceModeDefault: PerformanceMode.WARN
In which performance mode to run the app.
REFLEX_PERSIST_WEB_DIR
boolDefault: False
Whether to skip purging the web directory in dev mode.
REFLEX_REACT_OWNER_STACKS
boolDefault: False
Whether to keep React's development-build owner-stack capture in dev mode. Reflex disables it by default because the per-element Error() capture dominates dev-mode render CPU on large pages; enable it to restore full owner stacks in React DevTools and dev warnings.
REFLEX_REFERRER_PARAM
str | NoneDefault: None
Referrer identifier appended (urlencoded) to the "Built with Reflex" badge link as https://reflex.dev/?ref=<value>. Read at compile time.
REFLEX_SOCKET_INTERVAL
intDefault: 25
The interval to send a ping to the websocket server in seconds.
REFLEX_SOCKET_MAX_HTTP_BUFFER_SIZE
intDefault: 1000000
Maximum size of the message in the websocket server in bytes.
REFLEX_SOCKET_TIMEOUT
intDefault: 120
The timeout to wait for a pong from the websocket server in seconds.
REFLEX_SSR
boolDefault: True
Whether to enable SSR for the frontend.
REFLEX_STATES_WORKDIR
PathDefault: .states
The working directory for the states directory.
REFLEX_STATE_MANAGER_DISK_DEBOUNCE_SECONDS
floatDefault: 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
boolDefault: False
Whether to enable debug logging for the redis state manager.
REFLEX_STATE_SIZE_LIMIT
intDefault: 1000
The maximum size of the reflex state in kilobytes.
REFLEX_STRICT_HOT_RELOAD
boolDefault: 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
PathDefault: uploaded_files
The directory to store uploaded files.
REFLEX_USE_GRANIAN
boolDefault: False
Whether to use Granian for the backend. By default, the backend uses Uvicorn if available.
REFLEX_USE_NPM
boolDefault: False
Whether to use npm over bun to install and run the frontend.
REFLEX_USE_SYSTEM_BUN
boolDefault: False
Whether to use the system installed bun. If set to false, bun will be bundled with the app.
REFLEX_VITE_WARMUP_ROUTES
boolDefault: False
Pre-transform all route modules when the Vite dev server starts (experimental).
REFLEX_WEB_WORKDIR
PathDefault: .web
The working directory for the frontend directory.
SQLALCHEMY_ECHO
boolDefault: False
Whether to print the SQL queries if the log level is INFO or lower.
SQLALCHEMY_MAX_OVERFLOW
intDefault: 10
The maximum overflow size of the database connection pool.
SQLALCHEMY_POOL_PRE_PING
boolDefault: True
Whether to check db connections before using them.
SQLALCHEMY_POOL_RECYCLE
intDefault: -1
Recycle connections after this many seconds.
SQLALCHEMY_POOL_SIZE
intDefault: 5
The size of the database connection pool.
SQLALCHEMY_POOL_TIMEOUT
intDefault: 30
The timeout for acquiring a connection from the pool.
SSL_NO_VERIFY
boolDefault: False
Disable SSL verification for HTTPX requests.
VITE_EXPERIMENTAL_HMR
boolDefault: False
Whether to enable Rolldown's experimental HMR.
VITE_FORCE_FULL_RELOAD
boolDefault: False
Whether to force a full reload on changes.
VITE_HMR
boolDefault: True
Whether to enable hot module replacement
VITE_MINIFY
boolDefault: True
Whether to minify the frontend build output. Disabled by preview mode for readable bundles.
VITE_SOURCEMAP
LiteralDefault: False
Whether to generate sourcemaps for the frontend.