Skip to content
Latchkey

wrangler deploy: Usage, Options & Common CI Errors

Deploy your Cloudflare Worker to the edge.

wrangler deploy publishes a Worker (and its bindings) to Cloudflare. In CI you authenticate with an API token via environment variables rather than the interactive OAuth login.

What it does

wrangler deploy bundles your Worker per wrangler.toml, uploads it to Cloudflare, and activates it on the configured routes or workers.dev subdomain, wiring up bindings (KV, R2, D1, secrets). It replaced the older wrangler publish command in Wrangler v3+.

Common usage

Terminal
# Deploy using wrangler.toml
wrangler deploy

# Deploy to a named environment
wrangler deploy --env production

# CI: authenticate via env vars (no interactive login)
export CLOUDFLARE_API_TOKEN=xxxxxxxx
export CLOUDFLARE_ACCOUNT_ID=yyyyyyyy
wrangler deploy

Common error in CI: not authenticated / account id missing

deploy fails with "You are not authenticated. Please run wrangler login" or "More than one account available - please set CLOUDFLARE_ACCOUNT_ID". CI cannot do the interactive OAuth flow. Fix: set CLOUDFLARE_API_TOKEN (a scoped token with Workers permissions) and CLOUDFLARE_ACCOUNT_ID as environment variables on the runner; wrangler picks them up automatically. Set account_id in wrangler.toml as an alternative to the env var.

Key options

OptionPurpose
--env NAMEDeploy a named environment
--name NAMEOverride the Worker name
--dry-runBuild without uploading
--minifyMinify the Worker bundle

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →