For AI agents: the complete documentation index is at llms.txt. Remove the trailing slash from a page URL and append .md to read its Markdown version. For the docs home, use index.md.

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

Path

Default: alembic.ini

Path to the alembic config file

ALEMBIC_INCLUDE_SCHEMAS

bool

Default: False

Include schemas in alembic migrations.

APP_HARNESS_DRIVER

str

Default: Chrome

Which app harness driver to use.

Arguments to pass to the app harness driver.

APP_HARNESS_HEADLESS

bool

Default: False

Whether to run app harness tests in headless mode.

NPM_CONFIG_REGISTRY

str | None

Default: None

The npm registry to use.

Used by flexgen to enumerate the pages.

REFLEX_AUTO_RELOAD_COOLDOWN

timedelta

Default: 0:00:10

How long to wait between automatic reload on frontend error to avoid reload loops.

Deprecated in favour of REFLEX_AUTO_RELOAD_COOLDOWN.

REFLEX_BACKEND_COLD_START_TIMEOUT

timedelta

Default: 0:00:10

The timeout for the backend to do a cold start.

REFLEX_BACKEND_ONLY

bool

Default: False

Whether to run the backend only. Exclusive with REFLEX_FRONTEND_ONLY.

REFLEX_BACKEND_PORT

int | None

Default: None

The port to run the backend on.

Whether to check for outdated package versions.

REFLEX_DEV_PROD_REACT

bool

Default: False

Serve React's production build under the Vite dev server (experimental).

REFLEX_DIR

Path

Default: /home/runner/.local/share/reflex

The directory to store reflex dependencies.

Enables different behavior for when the backend would do a cold start if it was inactive.

REFLEX_ENABLE_FULL_LOGGING

bool

Default: False

Enable full logging of debug messages to reflex user directory.

REFLEX_ENV_MODE

Env

Default: Env.DEV

This env var stores the execution mode of the app

REFLEX_EXTRA_PLUGINS

list

Default: []

Extra plugins to append to the config's plugins list.

REFLEX_FRONTEND_ONLY

bool

Default: False

Whether to run the frontend only. Exclusive with REFLEX_BACKEND_ONLY.

REFLEX_FRONTEND_PORT

int | None

Default: None

The port to run the frontend on.

Paths to exclude from the hot reload. Takes precedence over include paths. Separated by a colon.

Additional paths to include in the hot reload. 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

Default: None

The address to bind the HTTP client to. You can set this to "::" to enable IPv6.

Whether to ignore the redis config error. Some redis servers only allow out-of-band configuration.

REFLEX_LOG_FILE

pathlib._local.Path | None

Default: 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

bool

Default: False

Emit logs as machine-readable JSON records instead of rich console output.

REFLEX_NO_AUTOPREFIXER

bool

Default: False

Read by the generated postcss.config.js to skip autoprefixer in preview mode.

REFLEX_OPLOCK_ENABLED

bool

Default: False

Whether to opportunistically hold the redis lock to allow fast in-memory access while uncontended.

REFLEX_OPLOCK_HOLD_TIME

timedelta

Default: 0:00:00

How long to opportunistically hold the redis lock (must be less than the token expiration).

Deprecated in favour of REFLEX_OPLOCK_HOLD_TIME.

REFLEX_PERF_MODE

PerformanceMode

Default: PerformanceMode.WARN

In which performance mode to run the app.

REFLEX_PERSIST_WEB_DIR

bool

Default: False

Whether to skip purging the web directory in dev mode.

REFLEX_REACT_OWNER_STACKS

bool

Default: 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_REDIS_MAX_CONNECTIONS

int | None

Default: None

Cap on connections in each redis client's pool; unset means unbounded. At the cap, callers wait for a free connection instead of opening a new one. Pub/sub listeners hold a connection each, so leave headroom.

REFLEX_REDIS_POOL_TIMEOUT

timedelta

Default: 0:00:02

How long to wait for a free redis connection once REFLEX_REDIS_MAX_CONNECTIONS is reached.

REFLEX_REFERRER_PARAM

str | None

Default: 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

timedelta

Default: 0:00:25

The interval to send a ping to the websocket server.

Maximum size of the message in the websocket server in bytes.

REFLEX_SOCKET_TIMEOUT

timedelta

Default: 0:02:00

The timeout to wait for a pong from the websocket server.

REFLEX_SSR

bool

Default: True

Whether to enable SSR for the frontend.

REFLEX_STATES_WORKDIR

Path

Default: .states

The working directory for the states directory.

REFLEX_STATE_MANAGER_DISK_DEBOUNCE

timedelta

Default: 0:00:02

How long to delay writing updated states to disk. (Higher values mean less writes, but more chance of lost data.)

Deprecated in favour of REFLEX_STATE_MANAGER_DISK_DEBOUNCE.

Whether to enable debug logging for the redis state manager.

REFLEX_STATE_SIZE_LIMIT

int

Default: 1000

The maximum size of the reflex state in kilobytes.

REFLEX_STRICT_HOT_RELOAD

bool

Default: 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

Default: uploaded_files

The directory to store uploaded files.

REFLEX_USE_GRANIAN

bool

Default: False

Whether to use Granian for the backend. By default, the backend uses Uvicorn if available.

REFLEX_USE_NPM

bool

Default: False

Whether to use npm over bun to install and run the frontend.

REFLEX_USE_SYSTEM_BUN

bool

Default: False

Whether to use the system installed bun. If set to false, bun will be bundled with the app.

REFLEX_VITE_WARMUP_ROUTES

bool

Default: False

Pre-transform all route modules when the Vite dev server starts (experimental).

REFLEX_WEB_WORKDIR

Path

Default: .web

The working directory for the frontend directory.

SQLALCHEMY_ECHO

bool

Default: False

Whether to print the SQL queries if the log level is INFO or lower.

The maximum overflow size of the database connection pool.

SQLALCHEMY_POOL_PRE_PING

bool

Default: True

Whether to check db connections before using them.

Recycle connections after this many seconds.

The size of the database connection pool.

SQLALCHEMY_POOL_TIMEOUT

timedelta

Default: 0:00:30

The timeout for acquiring a connection from the pool.

SSL_NO_VERIFY

bool

Default: False

Disable SSL verification for HTTPX requests.

VITE_EXPERIMENTAL_HMR

bool

Default: False

Whether to enable Rolldown's experimental HMR.

VITE_FORCE_FULL_RELOAD

bool

Default: False

Whether to force a full reload on changes.

VITE_HMR

bool

Default: True

Whether to enable hot module replacement

VITE_MINIFY

bool

Default: True

Whether to minify the frontend build output. Disabled by preview mode for readable bundles.

VITE_SOURCEMAP

Literal

Default: False

Whether to generate sourcemaps for the frontend.