Profiles
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, adefault profile is active and contains no settings overrides.
To view active settings from the command line, run:
Commonly configured settings
This section describes some commonly configured settings. See Configuring settings for details on setting and unsetting configuration values.PREFECT_API_KEY
ThePREFECT_API_KEY value specifies the API key used to authenticate with Prefect Cloud.
PREFECT_API_URL and PREFECT_API_KEY for your active profile, run prefect cloud login.
Read more about managing API keys.
PREFECT_API_URL
ThePREFECT_API_URL value specifies the API endpoint of your Prefect Cloud workspace or a self-hosted Prefect server instance.
For example, if using Prefect Cloud:
Host 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, you must also configure the Prefect server instance to connect to the API. ThePREFECT_UI_API_URL should be set to the external proxy URL
(for example, 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 set PREFECT_API_URL to the API URL.
This setting is a fallback if PREFECT_UI_API_URL is not set.
PREFECT_HOME
ThePREFECT_HOME value specifies the local Prefect directory for configuration files, profiles, and the location of the
default Prefect SQLite database.
PREFECT_LOCAL_STORAGE_PATH
ThePREFECT_LOCAL_STORAGE_PATH value specifies the default location of local storage for flow runs.
CSRF Protection Settings
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_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_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.
Database settings
If running a self-hosted Prefect server instance, there are several database configuration settings to consider.Logging settings
Prefect provides several logging configuration settings.Configure settings
Theprefect config CLI commands enable you to view, set, and unset settings.
| Command | Description |
|---|---|
| set | Change the value for a setting. |
| unset | Restore the default value for a setting. |
| view | Display the current settings. |
View settings from the CLI
Theprefect config view command displays settings that override default values.
--show-sources:
--show-defaults:
Set and clear values
Theprefect config set command lets you change the value of a default setting.
For example, you can set the PREFECT_API_URL to the location of Prefect server or your Cloud workspace:
instances or Prefect Cloud.
prefect config unset.
Override defaults with environment variables
All settings have keys that match the environment variable to override them. For example, to configure the home directory:Configuration profiles
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. Theprefect 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. |
prefect profile inspect displays those settings:
Create and remove profiles
Create a new profile with no settings:foo with settings cloned from an existing default profile:
Change values in profiles
Set a value in the current profile:--profile NAME option to a CLI command:
Inspect profiles
See a list of available profiles:Using profiles
Thedefault profile is used by default. There are several methods to switch to another profile.
We recommend using the prefect profile use command with the name of the profile:
PREFECT_PROFILE to the name of the profile:
foo:
-p flag as well:
Conflicts with environment variables
If setting the profile from the CLI with--profile, environment variables that conflict with settings in the profile are ignored.
In all other cases, environment variables take precedence over the value in the profile.
For example, a value set in a profile is used by default:
Profile files
Profiles are persisted to the file location specified byPREFECT_PROFILES_PATH.
The default location is a profiles.toml file in the PREFECT_HOME directory: