Table of Contents
The Error
Error: Error acquiring the state lock: timeout exceeded
What Causes This
A concurrent Terraform operation is holding the state lock, or a previous operation crashed without releasing it. The -lock-timeout period was exceeded.
How to Fix It
Solution 1: Increase Lock Timeout
terraform apply -lock-timeout=10m
Solution 2: Prevent Parallel Runs in CI/CD
# GitLab CI
deploy:
resource_group: terraform-prod
script:
- terraform apply -auto-approve
Solution 3: Force Unlock
# Verify no other operation is running first!
terraform force-unlock LOCK_ID_HERE
Prevention Tips
- Pin provider versions — avoid surprise breaking changes
- Use CI/CD — catch errors before they hit production
- Test with
terraform plan— always review before applying - Keep Terraform updated — newer versions have better error messages
- Use
terraform validate— catches syntax errors early
Hands-On Courses
- Terraform for Beginners on CopyPasteLearn
- Terraform By Example — practical code examples
- Terraform Cheat Sheet — quick reference for all commands
Related Articles
- Terraform Troubleshooting - Common Errors and Solutions
- Terraform Enabling and Using Debugging
- Debugging with TFLint
Conclusion
This error is common and fixable. Follow the solutions above, and check our Terraform course for hands-on training that covers real-world troubleshooting scenarios.

