Subchapter 1.8
references/TROUBLESHOOTING.mdMarkdown6 KBView on GitHub
Before debugging a failed command, run --help to confirm the flags you’re
using actually exist and are spelled correctly:
deno deploy create --help
deno deploy env --help
deno deploy database --helpExit code 2 almost always means a flag is missing or invalid — --help will
show you exactly what’s required.
This error occurs because the CLI needs an organization context. Unfortunately,
commands like deno deploy orgs also fail without this context.
Solution:
Find your org name manually: Visit https://console.deno.com (opens in a new tab) - your org is
in the URL path (e.g., console.deno.com/donjo means org is donjo)
Specify org explicitly:
deno deploy --org your-org-name --prodOr create an app with org:
deno deploy create --org your-org-name
# Complete the browser flow when promptedIf you see this error, the user needs to provide their organization name from the console URL.
Specify your entry file:
deno deploy --entrypoint main.ts --prodOr add to deno.json:
{
"deploy": {
"entrypoint": "main.ts"
}
}Token expired or missing. Options:
DENO_DEPLOY_TOKEN environment variableUser needs to upgrade Deno:
deno upgradeThe deno deploy command requires Deno >= 2.4.2.
Fresh 2.0 requires building before deployment:
deno task build
deno deploy --prodCheck what’s currently set:
deno deploy env listAdd missing variables:
deno deploy env add MISSING_VAR "value"The build succeeds but the deploy fails with a warmup error or exit code 1. This usually means the app crashes on startup.
Most common cause: The app connects to a database at startup (e.g.,
await initDb() in main.ts), but no database has been provisioned or assigned
yet.
Solution:
Provision and assign the database:
deno deploy database provision my-db --kind prisma --region us-east-1
deno deploy database assign my-db --app <APP_NAME>Redeploy:
deno deploy --prodFor a complete walkthrough, see the Fresh + PostgreSQL recipe.
When the CLI auto-detects Fresh or you use --framework-preset fresh, the
deploy may fail with an API error. This is a known issue.
Workaround: Use --do-not-use-detected-build-config and specify all build
commands manually:
deno deploy create \
--org <ORG_NAME> --app <APP_NAME> \
--source local \
--do-not-use-detected-build-config \
--install-command "deno install" \
--build-command "deno task build" \
--pre-deploy-command "echo ready" \
--runtime-mode dynamic --entrypoint main.ts \
--build-timeout 5 --build-memory-limit 1024 --region us| Error | Cause | Solution |
|---|---|---|
| “No organization was selected” | No org in config | Get org name from console URL, use --org flag |
| “No entrypoint found” | Can’t find main file | Use --entrypoint flag or set in deno.json |
| “authorization required” | Token expired/missing | Re-authenticate or set DENO_DEPLOY_TOKEN |
| “Minimum Deno version required” | Deno too old | Run deno upgrade |
| Exit code 2 (usage error) | Missing or invalid flags | Run deno deploy create --help to see required flags |
| Warmup failure (exit code 1) | App crashes on startup | Check for missing database or env vars — see Warmup Failure |
| Fresh preset API error | Auto-detection bug | Use --do-not-use-detected-build-config — see Fresh workaround |
The CLI output can be verbose. Look for these indicators of success:
.deno.dev or .deno.net - this is your live deploymenthttps://console.deno.com/<org>/<app>/builds/<id>After deployment, confirm success by extracting the production URL from the
output. The format is typically: https://<app-name>.<org>.deno.net or
https://<app-name>.deno.dev
These commands will error if no org is configured - do not try them to “discover” orgs:
deno deploy (without --org flag)deno deploy orgsdeno deploy switchdeno deploy env listdeno deploy logsVariables can apply to different environments:
# Set which contexts a variable applies to
deno deploy env update-contexts API_KEY Production PreviewAvailable contexts: Production, Preview, Local, Build