Terraform: Error: Failed to select workspace: workspace "staging" doesn't exist / Currently selected workspace "x" does not exist
The workspace you selected (or that .terraform/environment points to) isn't present in the backend.
Error: Failed to select workspace: workspace "staging" doesn't existCurrently selected workspace "x" does not existError: Workspace "staging" doesn't exist. You can create this workspace with the "new" subcommandError: Failed to select workspaceworkspace does not exist terraform Meaning
Create it (terraform workspace new staging) or select an existing one (terraform workspace list). With remote backends, state lives per workspace key/prefix; wrong backend config shows no workspaces. In CI use terraform workspace select -or-create staging.
Common causes
- Workspace never created
- Different backend/key prefix
.terraform/environmentstale- Workspace deleted
- TF_WORKSPACE env var set to a missing name
⚡ Quick fix
terraform workspace new NAMEorworkspace select -or-create NAME- Check backend
workspace_key_prefix/bucket - Unset a stale
TF_WORKSPACE
Detailed fix by platform
Terraform
terraform workspace list && terraform workspace select -or-create staging
How to diagnose
- List — Workspaces shown?
- Backend — Same config?
- Env — TF_WORKSPACE?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Backend configuration changed (migrate or reconfigure) Terraform: Error: Backend configuration changed — A change in the backend configuration has been detected, which may require migrating existing state
- Backend initialization required Terraform: Error: Backend initialization required, please run "terraform init" — Reason: Initial configuration of the requested backend "s3"
- Error building ARM Config: obtain subscription from Azure CLI Terraform: Error: building AzureRM Client: obtaining subscription ID / Please run 'az login' to setup account
Most viewed in Terraform
- Error acquiring the state lock Terraform: Error: Error acquiring the state lock — ConditionalCheckFailedException / state blob is already locked
- Inconsistent dependency lock file Terraform: Error: Inconsistent dependency lock file — provider x: required by this configuration but no version is selected
- Reference to undeclared resource Terraform: Error: Reference to undeclared resource / Reference to undeclared input variable
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026