terraform state ai_generated true

Error: Error acquiring the state lock

ID: terraform/state-lock-error

Also available as: JSON · Markdown
94%Fix Rate
96%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
115 active
1 active

Root Cause

Another Terraform process holds the state lock, or a previous run crashed without releasing it.

generic

Workarounds

  1. 85% success Wait for the other process to finish, then retry
    Check who holds the lock — the error message includes the lock ID and creator
  2. 93% success Use terraform force-unlock <LOCK_ID> only after confirming no other process is running
    Verify no other Terraform processes: ps aux | grep terraform

    Sources: https://developer.hashicorp.com/terraform/cli/commands/force-unlock

Dead Ends

Common approaches that don't work:

  1. Running terraform force-unlock immediately 70% fail

    May corrupt state if another process is genuinely running

  2. Deleting the lock file from the backend manually 80% fail

    Backend-specific and risky; may lose state data

Error Chain

Frequently confused with: