`terraform plan` takes 10 minutes and then fails with `Error acquiring the state lock` and `context deadline exceeded`, only from the corporate network.
IntermediateTroubleshootingState Locking and Backend Errors
Answer
Likely causes → A proxy or firewall blocks or slows the DynamoDB/S3 endpoint; HTTPS_PROXY is set but NO_PROXY routes VPC endpoints incorrectly; DNS resolves S3 to a private endpoint you can't reach.
Diagnose →
env | grep -i proxy
TF_LOG=DEBUG terraform plan 2>&1 | grep -E 'dynamodb|s3\.|timeout'
curl -sv https://dynamodb.ap-south-1.amazonaws.com 2>&1 | head
Fix → Configure the proxy correctly (and trust its CA via the OS store or AWS_CA_BUNDLE), or run Terraform from a runner inside the VPC.
Prevent → Run shared-state Terraform from controlled runners, not from laptops on varied networks. -lock-timeout=5m helps only with genuine contention, not network issues.
More on State Locking and Backend Errors
`terraform plan` fails with `Error acquiring the state lock` and `ConditionalCheckFailedException: The conditional request failed`.BeginnerWith the S3 backend and `use_lockfile = true`, you get `Error acquiring the state lock` with `StatusCode: 412` and `PreconditionFailed`.Intermediate`terraform force-unlock` returns `Failed to unlock state: lock ID "..." does not match existing lock`.BeginnerA teammate ran `terraform apply -lock=false` "because the lock was stuck". Now the plan shows resources you never touched being recreated.Advanced`terraform init` fails with `Error: Backend configuration changed`.Beginner`terraform init -migrate-state` asks `Do you want to copy existing state to the new backend?` and the new backend already has a state. What is the danger?Intermediate