Skip to content
Latchkey

OpenTofu "Backend configuration changed" in CI

OpenTofu detected that the backend block in your configuration no longer matches what the working directory was initialized with. It stops and asks you to reinitialize, choosing whether to migrate the existing state or reconfigure fresh.

What this error means

tofu init fails with "Error: Backend configuration changed" and "A change in the backend configuration has been detected ... Run \"tofu init\" with the -reconfigure or -migrate-state flags".

tofu
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 "tofu init
-migrate-state". If you wish to store the current configuration with no
changes to the state, use "tofu init -reconfigure".

Common causes

The backend block or partial config changed

A bucket, key, region, or table value in the backend (or a -backend-config value) differs from the initialized settings.

Migrating a Terraform backend to OpenTofu

Switching the tool or moving to a different backend changes the recorded config, so tofu requires an explicit reinit decision.

How to fix it

Reconfigure when the state target is unchanged

If you are pointing at the same state and only the tool or metadata changed, reinitialize without moving state.

Terminal
tofu init -reconfigure

Migrate state when moving backends

When the state should move to a new backend, let tofu copy it during init.

Terminal
tofu init -migrate-state

How to prevent it

  • Pass backend settings consistently via -backend-config in CI.
  • Choose -reconfigure vs -migrate-state deliberately, not by retry.
  • Keep backend values in one source so they do not drift between runs.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →