Table of Contents
The Error
Error: Error locking state: HTTP remote state endpoint returned 409
What Causes This
The HTTP-based state backend returned 409 Conflict because another run is in progress for this workspace.
How to Fix It
Solution 1: Cancel Active Run (Terraform Cloud)
# Via UI: Workspace > Runs > Cancel
# Via API:
curl -X POST -H "Authorization: Bearer $TFC_TOKEN" \
"https://app.terraform.io/api/v2/runs/RUN_ID/actions/cancel"
Solution 2: Wait and Retry
sleep 60
terraform apply
Solution 3: Unlock Workspace
curl -X POST -H "Authorization: Bearer $TFC_TOKEN" \
"https://app.terraform.io/api/v2/workspaces/$WS_ID/actions/unlock"
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.

