Solution skill
Terraform: "Error acquiring the state lock" means wait, then investigate
Complete solution
The most common scary error. It almost never means corruption; it means someone else holds the lock. This skill teaches reading the lock info, waiting it out, and when force-unlock is safe.
TL;DR: The most common scary error. It almost never means corruption; it means someone else holds the lock. Read the Lock Info. Never force-unlock because you are impatient.
The error
Error acquiring the state lockWhat you are seeing
Error: Error acquiring the state lock
Error message: ConditionalCheckFailedException: ...
Lock Info:
ID: abc123
Path: myapp-terraform-state/dev/terraform.tfstate
Operation: OperationTypeApply
Who: deploy-bot@ci-runner-4
Version: 1.9.0
Created: 2026-09-26 03:10:00 +0000 UTCState locking prevents two writes from corrupting the state file. This error means another process holds the lock. Reads (plan, refresh-only) generally do not need the lock; writes (apply, state mv) do.
First response
- Read the Lock Info.
WhoandCreatedtell you whether this is a live run or a corpse. A lock created two minutes ago by your CI pipeline is a live run: wait. - If it is your own pipeline, let the other run finish. Retrying apply in a loop does not help and can pile up queued runs.
- Only
terraform force-unlock [lock-id]when you have confirmed the holder is dead: crashed CI job, killed terminal, no terraform process running anywhere with that lock ID.
Rules for agents
- Never force-unlock because you are impatient. Two writers with one state file is how state gets corrupted.
terraform plan -lock=falseandterraform apply -lock=falsedisable locking entirely. This is a loaded gun: only for broken-lock emergencies you fully understand, never as a default.- Recurring stale locks point at infrastructure: CI jobs that get SIGKILLed, runners that die mid-apply. Fix the runner lifecycle, not the symptom.
- After any force-unlock, run
terraform planand read it fully before applying. If the killed run half-applied, the plan shows it.
When to use this
- You are seeing this exact error message; match the block above, not just part of it.
- The failing call matches the scenario in the title: Terraform.
- You want the fastest verified fix before digging through logs.
When not to use this
- Your error text differs from the block above; close cousins often have different causes.
- The stack trace points at a different component than the one in the title.
- You already applied this fix and the error persists; look for a second cause instead of reapplying.
Evidence
State locking docs: locks prevent concurrent writes; the error carries Lock Info (ID, Path, Operation, Who, Version, Created); force-unlock takes the lock ID; -lock=false disables locking. Verified against live docs 2026-09-26.
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_1c74LLBa2xVzGzvols-WFg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Terraform: "Error acquiring the state lock" means wait, then investigate <span>— Vectle</span></a>