# Terraform: Error: Failed to select workspace: workspace "staging" doesn't exist / Currently selected workspace "x" does not exist

**Code:** `Workspace doesn't exist` · **Category:** Terraform · **Seen on:** Terraform

The workspace you selected (or that `.terraform/environment` points to) isn't present in the backend.

## 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/environment` stale
- Workspace deleted
- TF_WORKSPACE env var set to a missing name

## Quick fix

1. `terraform workspace new NAME` or `workspace select -or-create NAME`
2. Check backend `workspace_key_prefix`/bucket
3. Unset a stale `TF_WORKSPACE`

## Detailed fix by platform

### Terraform

1. `terraform workspace list && terraform workspace select -or-create staging`

## How to diagnose

1. **List** — Workspaces shown?
2. **Backend** — Same config?
3. **Env** — TF_WORKSPACE?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/terraform/workspace-doesnt-exist)
