System environment variables
System environment variables are local environment variables that can change Wrangler's behavior. There are three ways to set system environment variables:
-
Create an
.envfile in your project directory. Set the values of your environment variables in your.envfile. This is the recommended way to set these variables, as it persists the values between Wrangler sessions. -
Inline the values in your Wrangler command. For example,
WRANGLER_LOG="debug" npx wrangler deploywill set the value ofWRANGLER_LOGto"debug"for this execution of the command. -
Set the values in your shell environment. For example, if you are using Z shell, adding
export CLOUDFLARE_API_TOKEN=...to your~/.zshrcfile will set this token as part of your shell configuration.
Wrangler supports the following environment variables:
-
CLOUDFLARE_ACCOUNT_IDstring optional- The account ID for the Workers related account.
-
CLOUDFLARE_API_TOKENstring optional- The API token for your Cloudflare account, can be used for authentication for situations like CI/CD, and other automation.
-
CLOUDFLARE_API_KEYstring optional- The API key for your Cloudflare account, usually used for older authentication method with
CLOUDFLARE_EMAIL=.
- The API key for your Cloudflare account, usually used for older authentication method with
-
CLOUDFLARE_EMAILstring optional- The email address associated with your Cloudflare account, usually used for older authentication method with
CLOUDFLARE_API_KEY=.
- The email address associated with your Cloudflare account, usually used for older authentication method with
-
WRANGLER_SEND_METRICSstring optional- Options for this are
trueandfalse. Defaults totrue. Controls whether Wrangler can send anonymous usage data to Cloudflare for this project. You can learn more about this in our data policy ↗.
- Options for this are
-
CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_<BINDING_NAME>string optional- The local connection string for your database to use in local development with Hyperdrive. For example, if the binding for your Hyperdrive is named
PROD_DB, this would beCLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_PROD_DB="postgres://user:password@127.0.0.1:5432/testdb". Each Hyperdrive is uniquely distinguished by the binding name.
- The local connection string for your database to use in local development with Hyperdrive. For example, if the binding for your Hyperdrive is named
-
CLOUDFLARE_API_BASE_URLstring optional- The default value is
"https://api.cloudflare.com/client/v4".
- The default value is
-
WRANGLER_LOGstring optional- Options for Logging levels are
"none","error","warn","info","log"and"debug". Levels are case-insensitive and default to"log". If an invalid level is specified, Wrangler will fallback to the default. Logs can include requests to Cloudflare's API, any usage data being collected, and more verbose error logs.
- Options for Logging levels are
-
WRANGLER_LOG_PATHstring optional- A file or directory path where Wrangler will write debug logs. If the path ends in
.log, Wrangler will consider this the path to a file where all logs will be written. Otherwise, Wrangler will treat the path as a directory where it will write one or more log files using a timestamp for the filenames.
- A file or directory path where Wrangler will write debug logs. If the path ends in
-
FORCE_COLORstring optional- By setting this to
0, you can disable Wrangler's colorised output, which makes it easier to read with some terminal setups. For example,FORCE_COLOR=0.
- By setting this to
-
WRANGLER_HTTPS_KEY_PATHstring optional- Path to a custom HTTPS certificate key when running
wrangler dev, to be used withWRANGLER_HTTPS_CERT_PATH.
- Path to a custom HTTPS certificate key when running
-
WRANGLER_HTTPS_CERT_PATHstring optional- Path to a custom HTTPS certificate when running
wrangler dev, to be used withWRANGLER_HTTPS_KEY_PATH.
- Path to a custom HTTPS certificate when running
DOCKER_HOSTstring optional- Used for local development of Containers. Wrangler will attempt to automatically find the correct socket to use to communicate with your container engine. If that does not work (usually surfacing as an
internal errorwhen attempting to connect to your Container), you can try setting the socket path using this environment variable.
- Used for local development of Containers. Wrangler will attempt to automatically find the correct socket to use to communicate with your container engine. If that does not work (usually surfacing as an
WRANGLER_R2_SQL_AUTH_TOKENstring optional- API token used for executing queries with R2 SQL.
The following is an example .env file:
CLOUDFLARE_ACCOUNT_ID=<YOUR_ACCOUNT_ID_VALUE>CLOUDFLARE_API_TOKEN=<YOUR_API_TOKEN_VALUE>CLOUDFLARE_EMAIL=<YOUR_EMAIL>WRANGLER_SEND_METRICS=trueCLOUDFLARE_API_BASE_URL=https://api.cloudflare.com/client/v4WRANGLER_LOG=debugWRANGLER_LOG_PATH=../Desktop/my-logs/my-log-file.logWRANGLER_R2_SQL_AUTH_TOKEN=<YOUR_R2_API_TOKEN_VALUE>The following variables are deprecated. Use the new variables listed above to prevent any issues or unwanted messaging.
CF_ACCOUNT_IDCF_API_TOKENCF_API_KEYCF_EMAILCF_API_BASE_URL
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark