# Error Locking state

**URL:** <https://discuss.hashicorp.com/t/error-locking-state/12437>\
**Category:** Terraform\
**Created:** [August 5, 2020, 3:38pm UTC](https://discuss.hashicorp.com/t/error-locking-state/12437 "2020-08-05T15:38:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Devanshu26](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/devanshu26/32/10205_2.png) [@Devanshu26](https://discuss.hashicorp.com/u/Devanshu26)\
**Post date:** [August 5, 2020, 3:38pm UTC](https://discuss.hashicorp.com/t/error-locking-state/12437/1 "2020-08-05T15:38:39Z")

</div>

Hi Guys,

I am new to terraform and just installed terraform on my personal Windows machine.  
I am getting output for “terraform --version” command but when i am executing terraform console then i am getting below error.

Error: Error locking state: Error acquiring the state lock: open terraform.tfstate: Access is denied.

Please suggust, how to resolve it.

---

<div class="post-metadata">

**Author:** ![javierruizjimenez](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/javierruizjimenez/32/10134_2.png) [@javierruizjimenez](https://discuss.hashicorp.com/u/javierruizjimenez)\
**Post date:** [August 5, 2020, 8:37pm UTC](https://discuss.hashicorp.com/t/error-locking-state/12437/2 "2020-08-05T20:37:57Z")

</div>

Hi @Devanshu26

Welcome to Terraform and the forums. It is a great tool once you understand it.

I don’t use Windows but the errors could indicate that another process is “holding” the lock, it can actually be a previous console or another execution of `terraform plan / apply / ...`.

> [@Devanshu26](#):
>
> Error: Error locking state: Error acquiring the state lock:

I suggest you use Process Explorer from Mark Russinovich to find out who is holding a lock:

> **[Process Explorer - Sysinternals](https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer)**
>
> Find out what files, registry keys and other objects processes have open, which DLLs they have loaded, and more.

In Linux, the lock is a file with name .terraform.tfstate.lock.info that is located in the same directory as your Terraform files. It is a hidden file, in Windows it is probably hidden as well so make sure to show hidden files.

You can use the search function in Process Explorer to find the process holding the lock, try with the directory path if you don’t know the name.

Please let us know if you find the root cause.

Thanks  
Javier

---

<div class="post-metadata">

**Author:** ![Devanshu26](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/devanshu26/32/10205_2.png) [@Devanshu26](https://discuss.hashicorp.com/u/Devanshu26)\
**Post date:** [August 6, 2020, 12:33pm UTC](https://discuss.hashicorp.com/t/error-locking-state/12437/3 "2020-08-06T12:33:22Z")

</div>

Hi Javier,

Yes, there was another process that was holding terraform.  
Firstly, i killed all other terraform related process and then need to execute below command to unlock state  
terraform force-unlock -force [LOCK\_ID]

After that check the current state of terraform by  
terraform show.

Now i am able to open terraform console and it’s working fine.

Thanks  
Devanshu
