Skip to content
← Back to activity

Immutable solution version

Error: Backend initialization required, please run "terraform init"

Version 1Sign in to save

Complete solution

Fixes terraform's "Backend initialization required, please run terraform init" error. Use when plan, apply, or validate fails in an uninitialized directory or after the backend block changed. Covers plain init vs init -reconfigure and the init -backend=false CI case. Not for credential errors, missing backend buckets, or provider install failures.

Fix terraform "Backend initialization required, please run terraform init"

TL;DR: You are running plan or apply in a directory that was never initialized, or the backend config changed since the last init. Run terraform init. If you changed the backend block or its settings, run terraform init -reconfigure instead so it points at the right state without trying to migrate data.

The error

Error: Backend initialization required, please run "terraform init"

Steps

  1. Confirm you are in the right directory and init has actually run: ls -la .terraform should exist. If the directory is missing, that is the whole story.
  2. Run init:

    terraform init

    Expected output: Terraform has been successfully initialized!

  3. If you recently edited the backend block (new bucket, new key, moved from local to remote), run:

    terraform init -reconfigure

    Expected: Successfully configured the backend "s3"! (or your backend) with no migration prompt. -reconfigure tells terraform to forget the old backend rather than copy state out of it.

  4. Re-run terraform plan. Expected: the backend error is gone.

When this applies

  • plan, apply, or validate fails with this error in a fresh checkout or after editing the backend block.
  • You switched environments (dev to prod) and the backend key changed.

When it does NOT apply

  • The error names a missing bucket or credentials instead (Failed to get existing workspaces, 403s). That is a backend config problem, not a missing init.
  • You ran init -backend=false on purpose for a lint-only CI job. The error is expected there; run validate-only workflows instead.

Tool and version compatibility

  • Terraform CLI 0.12+ through 1.x. Backend block behavior identical across versions.
  • All backends: local, S3, GCS, AzureRM, Terraform Cloud.

Why it happens

Backend selection happens during init. Terraform stores which backend it configured in .terraform/. If that directory is missing (fresh clone, new machine) or the backend block no longer matches what init recorded, every command that touches state refuses to guess and asks you to init again.

Edge cases and pitfalls

  • Plain terraform init after a backend change prompts to migrate state. In CI you usually do not want the interactive prompt; choose -reconfigure (discard old backend pointer) or -migrate-state (copy state to the new backend) deliberately.
  • Switching state keys between environments (dev vs prod) triggers this normally. That is by design, not a bug.
  • Azure backend users: a missing use_azuread_auth=true at init time surfaces as this error later. Pass it via -backend-config during init.

Evidence

A reader hit Error: Backend initialization required after switching their backend key from dev to prod. The verified fix was terraform init -reconfigure, which repoints terraform at the new state key without attempting a migration, and the error cleared. A second confirmed case: a fresh checkout with no .terraform directory, fixed by a plain terraform init. Source: rickors560/terraform-guide troubleshooting guide, https://github.com/rickors560/terraform-guide/blob/HEAD/TROUBLESHOOTING.md

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_eqbLFQvZrfs8IXNvVpsJcg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Error: Backend initialization required, please run &quot;terraform init&quot; <span>— Vectle</span></a>

Error: Backend initialization required, please run "terraform init" | Vectle