Skip to main content
terraformintermediateconfigurationVerified

Terraform State Lock Error: Causes and Fixes

Last reviewed: 9/14/2026
3 solutions

Exact Error Message

Error: Error acquiring the state lock

Quick Fix

Check if another Terraform operation is running, or force unlock if safe: terraform force-unlock LOCK_ID

What This Error Means

Terraform uses state locking to prevent concurrent modifications that could corrupt state. This error occurs when another Terraform operation is currently running or when a lock wasn't properly released after a crash.

Common Symptoms
  • Terraform apply/plan fails with lock error
  • Cannot run concurrent Terraform operations
  • State appears stuck after crash
Common Causes
  • Another Terraform operation is still running
  • Previous operation crashed without releasing lock
  • Network issues preventing lock release
  • Manual lock held by another team member
  • Backend connectivity issues
Diagnostic Steps
  1. 1Check if anyone else is running Terraform
  2. 2Review Terraform Cloud/Enterprise for active runs
  3. 3Check backend connectivity
  4. 4Review crash logs from failed operation
  5. 5Verify lock information in backend

Solutions

Solution 1: Wait for existing operation to complete
  1. 1Check with team if anyone is running Terraform
  2. 2Wait for the existing operation to finish
  3. 3Retry your operation after lock is released
Solution 2: Force unlock state lock (use with caution)
  1. 1Confirm no other operations are actively running
  2. 2Get the lock ID from error message
  3. 3Run force unlock command
  4. 4Immediately retry your operation

Commands to Run

Force unlock can cause state corruption if another operation is actively writing

terraform force-unlock LOCK_ID
Solution 3: Fix backend connectivity
  1. 1Verify backend configuration
  2. 2Test backend connectivity
  3. 3Check authentication credentials
  4. 4Review backend service status

Commands to Run

Reconfiguring backend may require re-authentication

terraform init -reconfigure
Prevention Tips
  • Use Terraform Cloud/Enterprise for team collaboration
  • Implement proper communication for state changes
  • Use workspaces for environment isolation
  • Monitor Terraform operations
  • Set appropriate lock timeouts

Version Notes: Applies to Terraform 1.0+

Was this helpful?