Prefect's local settings are documented and type-validated.
By modifying the default settings, you can customize various aspects of the system.
You can override a setting with an environment variable or by updating the setting in a Prefect profile.
Prefect profiles are persisted groups of settings on your local machine. A single profile is always active.
Initially, a default profile named default is active and contains no settings overrides.
All currently active settings can be viewed from the command line by running the following command:
prefectconfigview--show-defaults
When you switch to a different profile, all of the settings configured in the newly activated profile are applied.
The PREFECT_API_KEY value specifies the API key used to authenticate with Prefect Cloud.
PREFECT_API_KEY="[API-KEY]"
Generally, you will set the PREFECT_API_URL and PREFECT_API_KEY for your active profile by running prefect cloud login.
If you're curious, read more about managing API keys.
If using a local Prefect server instance, set your API URL like this:
PREFECT_API_URL="http://127.0.0.1:4200/api"
PREFECT_API_URL setting for workers
If using a worker (agent and block-based deployments are legacy) that can create flow runs for deployments in remote environments, PREFECT_API_URL must be set for the environment in which your worker is running.
If you want the worker to communicate with Prefect Cloud or a Prefect server instance from a remote execution environment such as a VM or Docker container, you must configure PREFECT_API_URL in that environment.
Running the Prefect UI behind a reverse proxy
When using a reverse proxy (such as Nginx or Traefik) to proxy traffic to a locally-hosted Prefect UI instance, the Prefect server instance also needs to be configured to know how to connect to the API.
The PREFECT_UI_API_URL should be set to the external proxy URL (e.g. if your external URL is https://prefect-server.example.com/ then set PREFECT_UI_API_URL=https://prefect-server.example.com/api for the Prefect server process).
You can also accomplish this by setting PREFECT_API_URL to the API URL, as this setting is used as a fallback if PREFECT_UI_API_URL is not set.
The PREFECT_HOME value specifies the local Prefect directory for configuration files, profiles, and the location of the default Prefect SQLite database.
If using a local Prefect server instance, you can configure CSRF protection settings.
PREFECT_SERVER_CSRF_PROTECTION_ENABLED
- Activates CSRF protection on the server, requiring valid CSRF tokens for applicable requests. Recommended for production to prevent CSRF attacks. Defaults to False.
PREFECT_SERVER_CSRF_PROTECTION_ENABLED=True
PREFECT_SERVER_CSRF_TOKEN_EXPIRATION
- Sets the expiration duration for server-issued CSRF tokens, influencing how often tokens need to be refreshed. The default is 1 hour.
PREFECT_SERVER_CSRF_TOKEN_EXPIRATION='3600'# 1 hour in seconds
By default clients expect that CSRF protection is enabled on the server. If you are running a server without CSRF protection, you can disable CSRF support in the client.
PREFECT_CLIENT_CSRF_SUPPORT_ENABLED
- Enables or disables CSRF token handling in the Prefect client. When enabled, the client manages CSRF tokens for state-changing API requests. Defaults to True.
The prefect config set command lets you change the value of a default setting.
A commonly used example is setting the PREFECT_API_URL, which you may need to change when interacting with different Prefect server instances or Prefect Cloud.
# use a local Prefect server
prefectconfigsetPREFECT_API_URL="http://127.0.0.1:4200/api"# use Prefect Cloud
prefectconfigsetPREFECT_API_URL="https://api.prefect.cloud/api/accounts/[ACCOUNT-ID]/workspaces/[WORKSPACE-ID]"
If you want to configure a setting to use its default value, use the prefect config unset command.
Prefect allows you to persist settings instead of setting an environment variable each time you open a new shell.
Settings are persisted to profiles, which allow you to move between groups of settings quickly.
The prefect profile CLI commands enable you to create, review, and manage profiles.
Command
Description
create
Create a new profile.
delete
Delete the given profile.
inspect
Display settings from a given profile; defaults to active.
ls
List profile names.
rename
Change the name of a profile.
use
Switch the active profile.
If you configured settings for a profile, prefect profile inspect displays those settings:
Profiles are persisted to the file location specified by PREFECT_PROFILES_PATH.
The default location is a profiles.toml file in the PREFECT_HOME directory: