terraform plan
╷
│ Error: Error acquiring the state lock
│
│ Error message: resource temporarily unavailable
│ Lock Info:
│ ID: 9bc5aaea-198e-7874-dc5a-3b04c8388571
│ Path: /home/coder/.local/share/code-server/User/de-c1w4-058264065348-us-east-1-terraform-state.state
│ Operation: OperationTypeApply
│ Who: coder@11abe7b3e3df
│ Version: 1.9.8
│ Created: 2025-02-05 17:49:57.4175219 +0000 UTC
│ Info:
│
│
│ Terraform acquires a state lock to protect the state from being written
│ by multiple users at the same time. Please resolve the issue above and try
│ again. For most commands, you can disable locking with the “-lock=false”
│ flag, but this is not recommended.
is there any command to unlock this this ?? i feel the "“OS lock”
THE EASY WAY TO SOLVE IS
ps aux | grep terraform
Then, kill any stuck Terraform processes:
sh
CopyEdit
kill -9 <PID>
if this not work(terraform - Error acquiring the state lock: ConditionalCheckFailedException - Stack Overflow)
Hello @Muhammad_Hassaan,
Thanks for sharing this, hopefully a new lab session (when two hours pass) fixes previous states and clears resources . A terminal disconnect might cause this error and hopefully fixes after the cleanup phase.
If you complete this form a lab refresh seems to fix all those issues, it should take 2-3 business days. Thank you
1 Like