This error means the backend block in your configuration no longer matches what Terraform initialized last time. Terraform records the backend settings at init and refuses to proceed if they change underneath it, because a silent backend switch could point you at the wrong state or lose track of your resources. Something in the block changed: the bucket, the key, the region, or the backend type itself. The fix is to re-init with the flag that matches your intent, and choosing the right one matters.
Error: Backend configuration changed
A change in the backend configuration has been detected, which may require
migrating existing state.
If you wish to attempt automatic migration of the state, use
"terraform init -migrate-state".
If you wish to store the current configuration with no changes to the state,
use "terraform init -reconfigure".
What this error means
Terraform reads the backend block only during init and stores a fingerprint of it in the .terraform directory alongside a pointer to your state. On the next command it compares the current backend block against that fingerprint. If they differ, it stops and asks you to re-init, because it cannot know whether you meant to move the same state to a new location or to point at a genuinely different state. It offers two paths: migrate the existing state, or reconfigure and ignore the old state. You have to tell it which.
Common causes
- The state bucket, key, or prefix changed, for example moving from one S3 key to a per environment key.
- The region or other backend settings changed.
- The backend type changed, such as moving from local to S3 or from S3 to Terraform Cloud.
- Backend settings were moved out to a partial config or
-backend-configfile and the values differ. - A refactor into workspaces or a different directory layout that shifts where state lives.
How to fix it
Stabilize
- Do not delete the
.terraformdirectory to make the error go away. That discards the record of where your real state lives and turns a clear prompt into a guessing game. Instead, back up your current state before touching anything.
terraform state pull > backup.tfstate
Diagnose
- Compare what changed in the backend block against version control so you know exactly what moved.
git diff -- main.tf
- Decide your intent. Are you moving the same state to a new location, or pointing at a different or fresh backend? That single question chooses the flag.
Fix
If you are moving the same state to a new backend or new key and want to keep managing the same resources, migrate. Terraform copies the existing state to the new backend and prompts for confirmation.
terraform init -migrate-state
If the old backend is gone or wrong and you intend to initialize the new one without copying anything, reconfigure. Use this only when you are sure you do not need the old state copied over.
terraform init -reconfigure
After init, run a plan and confirm it shows no unexpected creations. If a plan that should be empty suddenly wants to create everything, you reconfigured when you should have migrated; stop, restore from backup.tfstate, and migrate instead.
terraform plan
How to prevent it
- Change backend settings deliberately and re-init in the same commit, so the config and the stored fingerprint stay in step.
- Keep backend values in a partial config or
-backend-configfile so the block itself changes less often. - Always run a plan right after re-init and confirm it is empty when you expect no changes.
- Back up state with
terraform state pullbefore any backend change, so a wrong flag is recoverable. - Document your state layout (bucket, key scheme, workspaces) so teammates do not accidentally repoint it.
When to call a senior engineer
If you are unsure whether to migrate or reconfigure, if a re-init has already produced a plan that wants to recreate live resources, or if you are consolidating or splitting state across backends and workspaces, this is state surgery and mistakes here duplicate or strand real infrastructure. Erzon engineers can map where your state actually lives, migrate it safely, and verify with a clean plan that Terraform is still managing exactly the resources you already run.
Related errors we fix
Error: Cycle: ... Fix this error → Terraform Error: Error acquiring the state lock Fix this error → Terraform Error: Instance cannot be destroyed Fix this error → Terraform Error: Invalid count argument ... the "count" value depends on resource attributes that cannot be determined until apply Fix this error → Want a senior engineer to just fix it?
Paste this exact error into the form. A senior engineer replies within one business hour with what is likely wrong and a flat quote. Triage is free.
Book a fix