How to fix Error: Saved plan is stale in Terraform

TerraformBEGINNERHIGHUpdated Dec 30, 2025· 189 views

A saved Terraform plan can no longer be applied because the state was modified after the plan was created. Regenerating the plan resolves this issue.

Quick fix

Fixes Error: Saved plan is stale

rm tfplan
  1. Delete the stale plan file
  2. Regenerate the plan
  3. Apply the new plan
  4. For CI/CD: Use -reconfigure if needed
terraform — error
rm tfplan
Error: Saved plan is stale

What this error means

Terraform plans are bound to a specific state snapshot. When you run terraform plan, Terraform captures the current state and creates a plan based on what changes are needed. If the state is modified by another operation before you apply the plan, Terraform detects the mismatch and rejects the application. This safety mechanism prevents applying plans that may be based on outdated infrastructure state, which could cause unexpected resource modifications or conflicts.

Typical symptoms

  • terraform apply fails with 'Saved plan is stale' error message
  • Error occurs even when no changes have been made to configuration
  • Plan applies successfully in one CI/CD stage but fails in subsequent stages
  • Error happens immediately after state is modified by concurrent operations
  • terraform show command fails with stale plan error

Common causes

  1. State was modified by another terraform apply operation after the plan was created
  2. Concurrent CI/CD pipelines or team members running terraform apply simultaneously
  3. Data sources that generate values on every apply (random, timestamps) incrementing state serial
  4. State backend's 'Last Modified' timestamp changed even though content didn't change
  5. State blob was modified by infrastructure drift detection or manual updates
  6. Multiple environments or workspaces sharing the same state or backend credentials

How to fix "Error: Saved plan is stale"

1Delete the stale plan file

Remove the saved plan file from your working directory. This is the quickest solution for local development:

bash
rm tfplan

Or if your plan file has a different name:

bash
rm [plan-filename]

This prevents Terraform from attempting to use outdated plan data.

2Regenerate the plan

Create a fresh plan based on the current state:

bash
terraform plan -out=tfplan

This reads the latest state and compares it against your current configuration. Any changes since the previous plan will be captured in the new plan file.

3Apply the new plan

Apply the newly generated plan:

bash
terraform apply tfplan

Since this plan was just created, it matches the current state and will apply successfully.

4For CI/CD: Use -reconfigure if needed

If you're in a CI/CD pipeline and the state has changed between stages, use -reconfigure to force Terraform to detect the current state:

bash
terraform init
terraform plan -out=tfplan
terraform apply tfplan

Always run terraform init in CI/CD pipelines to ensure plugin cache and backend configuration are properly set up before planning.

5Investigate what changed in state (optional)

To understand what caused the state to change, compare the old and new plans:

bash
terraform show -no-color tfplan.old > tfplan.old.txt
terraform plan -no-color > tfplan.new.txt
diff tfplan.old.txt tfplan.new.txt

This shows you what infrastructure differences Terraform detected between plan generations.

Advanced notes

Data Source Drift: Some data sources generate new values on every apply (like random providers or timestamp functions). These cause the state serial to increment even though no resources changed. To debug this, check your terraform logs with TF_LOG=DEBUG.

CI/CD Pipeline Considerations: In multi-stage pipelines, ensure only one stage can run terraform apply at a time. Use state locking with backends like S3+DynamoDB, Azure Blob Storage, or Terraform Cloud to prevent concurrent modifications.

State Locking: Verify your backend supports state locking:

hcl
terraform {
  backend "s3" {
    dynamodb_table = "terraform-locks"
  }
}

Azure-Specific Issue: On Azure, the error may trigger based on blob 'Last Modified' timestamp changes rather than actual content changes. Consider using Terraform Cloud or Enterprise for more reliable state locking.

Terragrunt Users: If using Terragrunt across multiple environments, ensure each environment has isolated state. A common cause is sharing state between stages when using artifacts.

Frequently asked questions

What does "Error: Saved plan is stale" mean?
Terraform plans are bound to a specific state snapshot. When you run terraform plan, Terraform captures the current state and creates a plan based on what changes are needed. If the state is modified by another operation before you apply the plan, Terraform detects the mismatch and rejects the application.
How do I fix "Error: Saved plan is stale"?
A saved Terraform plan can no longer be applied because the state was modified after the plan was created. Regenerating the plan resolves this issue.
What causes "Error: Saved plan is stale"?
State was modified by another terraform apply operation after the plan was created Concurrent CI/CD pipelines or team members running terraform apply simultaneously Data sources that generate values on every apply (random, timestamps) incrementing state serial
Is the "Error: Saved plan is stale" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading