Error: Backend configuration changed: re-run terraform init -reconfigure
Fixes Terraform's "Error: Backend configuration changed" when backend settings differ from the initialized state. Use when init or plan fails after editing the backend block. Run terraform init -reconfigure (or -migrate-state to move state); never edit .terraform/terraform.tfstate manually.
TL;DR
You edited the backend block after terraform init already recorded the old settings. Terraform refuses to guess which config is authoritative. Re-run terraform init -reconfigure (same backend, new settings) or terraform init -migrate-state (moving state to a new backend).
The error
Error: Backend configuration changed(Terraform shows the diff between the saved backend config and the current one.)
Steps to fix
- Decide what changed: same backend with new settings (new bucket/key/region), or a genuinely different backend?
- Expected: you know whether state needs to move.
- Same backend, new settings:
terraform init -reconfigure- Expected:
Terraform has been successfully initialized!
Moving state to a new backend:
terraform init -migrate-state- Expected: Terraform prompts to copy state; answer yes after checking the target is empty.
- Run
terraform planand confirm it sees the expected state.
- Expected: plan reflects your real infrastructure, not an empty state.
When to use this
- Any command fails with
Backend configuration changedafter editing theterraform { backend ... }block or its-backend-configinputs.
When NOT to use this
Backend initialization requiredmeans init never ran. If the new backend already has state,-migrate-statewould overwrite it; use-reconfigureto just switch the pointer.
Compatibility
- All Terraform versions;
-reconfigureand-migrate-stateflags are stable.
Root cause
terraform init snapshots the backend configuration into .terraform/. Later commands compare the config against that snapshot; any difference aborts, because applying new backend settings silently could read or write the wrong state.
Edge cases
- In CI, backend settings often come from
-backend-configflags; a changed flag value triggers this too. -reconfigurediscards the old backend without moving state; if the old backend held the only copy, you lose access to it. Back up first withterraform state pull.- Workspaces: reconfigure keeps the selected workspace if it exists in the new backend.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.