<p>Make sure that there is no other instance of Bitcoin Core running on your system. Once you are absolutely sure that nothing else is using the data directory, delete the files named <code>.lock</code> and <code>.walletlock</code> within it. Then start Bitcoin Core.</p>

CC BY-SA 4.0
2019-12-22T23:32:43.403Z
As I wrote, ```ps -aux | grep bitcoin``` retuns no running bitcoind process. It is not a simple problem. I think it might come from a side effect of some issue and it reporteed as a lock problem, when it makes no sense - the .lock file is created. I delete it, restart, it is created again. There must be some silent error in the background. I have no idea where is the root problem...
sugarman
CC BY-SA 4.0
2019-12-23T01:32:15.113Z
The `.lock` file is supposed to be created by bitcoind which will then remove it during the shut down process.  The issue comes from the lock file being there when bitcoind is not running. You also need to remove the `.walletlock` file too.
Ava Chow
CC BY-SA 4.0
2019-12-23T01:33:12.173Z
After looking at your debug.log snippet more closely, your error is actually due to the `.walletlock` file.
Ava Chow
CC BY-SA 4.0
2019-12-22T22:32:31.233Z
2019-12-23T01:32:26.743Z
2019-12-23T01:32:26.743Z
Ava Chow
<p>Hello fellow bitcoiners,</p>

<p>I have a very annoying and mysterious issue with a bitcoind install. I had a blockchain corruption/stuck at some point. I deleted the old blockchain and copied an up-to-date blockchain from another machine. And now bitcoind does not succeed to run. When launched it complains about: "Cannot obtain a lock on wallet directory". I have deleted the .lock file, bitcoind obviously not running. After relaunch, the file gets created again. <code>ps -aux | grep bitcoin</code> returns no running process. bitoind starts (as a systemd service, which wasn't modified and run perfectly before, not in question). After the blockchain copy I chown the blockchain directory to the correct user on the target machine. I have enven  tried chown 777 giving all possible rights on the blockchain directory. Still have the lock issue.</p>

<p>Here is the debug log:</p>

<pre><code>2019-12-22T21:26:19Z Using data directory /usr/local/bitc/blockchain
2019-12-22T21:26:19Z Config file: /usr/local/bitc/blockchain/bitcoin.conf
2019-12-22T21:26:19Z Using at most 125 automatic connections (1024 file descriptors available)
2019-12-22T21:26:19Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2019-12-22T21:26:19Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2019-12-22T21:26:19Z Using 4 threads for script verification
2019-12-22T21:26:19Z scheduler thread start
2019-12-22T21:26:20Z HTTP: creating work queue of depth 16
2019-12-22T21:26:20Z No rpcpassword set - using random cookie authentication.
2019-12-22T21:26:20Z Generated RPC authentication cookie /usr/local/bitc/blockchain/.cookie
2019-12-22T21:26:20Z HTTP: starting 4 worker threads
2019-12-22T21:26:20Z Using wallet directory /usr/local/bitc/blockchain
2019-12-22T21:26:20Z init message: Verifying wallet(s)...
2019-12-22T21:26:20Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
2019-12-22T21:26:20Z Using wallet /usr/local/bitc/blockchain
2019-12-22T21:26:20Z ERROR: Error while attempting to lock directory /usr/local/bitc/blockchain: Permission denied
2019-12-22T21:26:20Z Cannot obtain a lock on wallet directory /usr/local/bitc/blockchain. Another instance of bitcoin may be using it.
2019-12-22T21:26:20Z Error: Error initializing wallet database environment "/usr/local/bitc/blockchain"!
2019-12-22T21:26:20Z Shutdown: In progress...
2019-12-22T21:26:20Z scheduler thread interrupt
2019-12-22T21:26:20Z Shutdown: done
</code></pre>

<p>Does anyone has a clue?</p>

<p>Best regards, cr!ptal.</p>

<bitcoin-core><wallet><bitcoind>
bitcoind: cannot obtain a lock on wallet directory
sugarman
# bitcoind: cannot obtain a lock on wallet directory

(Asked by: username_0 on 2019-12-22)

Hello fellow bitcoiners,

I have a very annoying and mysterious issue with a bitcoind install. I had a blockchain corruption/stuck at some point. I deleted the old blockchain and copied an up-to-date blockchain from another machine. And now bitcoind does not succeed to run. When launched it complains about: "Cannot obtain a lock on wallet directory". I have deleted the .lock file, bitcoind obviously not running. After relaunch, the file gets created again. `ps -aux | grep bitcoin` returns no running process. bitoind starts (as a systemd service, which wasn't modified and run perfectly before, not in question). After the blockchain copy I chown the blockchain directory to the correct user on the target machine. I have enven tried chown 777 giving all possible rights on the blockchain directory. Still have the lock issue.

Here is the debug log:

```
2019-12-22T21:26:19Z Using data directory /usr/local/bitc/blockchain
2019-12-22T21:26:19Z Config file: /usr/local/bitc/blockchain/bitcoin.conf
2019-12-22T21:26:19Z Using at most 125 automatic connections (1024 file descriptors available)
2019-12-22T21:26:19Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2019-12-22T21:26:19Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2019-12-22T21:26:19Z Using 4 threads for script verification
2019-12-22T21:26:19Z scheduler thread start
2019-12-22T21:26:20Z HTTP: creating work queue of depth 16
2019-12-22T21:26:20Z No rpcpassword set - using random cookie authentication.
2019-12-22T21:26:20Z Generated RPC authentication cookie /usr/local/bitc/blockchain/.cookie
2019-12-22T21:26:20Z HTTP: starting 4 worker threads
2019-12-22T21:26:20Z Using wallet directory /usr/local/bitc/blockchain
2019-12-22T21:26:20Z init message: Verifying wallet(s)...
2019-12-22T21:26:20Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
2019-12-22T21:26:20Z Using wallet /usr/local/bitc/blockchain
2019-12-22T21:26:20Z ERROR: Error while attempting to lock directory /usr/local/bitc/blockchain: Permission denied
2019-12-22T21:26:20Z Cannot obtain a lock on wallet directory /usr/local/bitc/blockchain. Another instance of bitcoin may be using it.
2019-12-22T21:26:20Z Error: Error initializing wallet database environment "/usr/local/bitc/blockchain"!
2019-12-22T21:26:20Z Shutdown: In progress...
2019-12-22T21:26:20Z scheduler thread interrupt
2019-12-22T21:26:20Z Shutdown: done

```

Does anyone has a clue?

Best regards, cr!ptal.

**Tags:** bitcoin-core, wallet, bitcoind


---

## 1 answers

### Answer by username_1 on 2019-12-22. Score: 1

Make sure that there is no other instance of Bitcoin Core running on your system. Once you are absolutely sure that nothing else is using the data directory, delete the files named `.lock` and `.walletlock` within it. Then start Bitcoin Core.

> **Comments:**
> **username_0**: As I wrote, ```ps -aux | grep bitcoin``` retuns no running bitcoind process. It is not a simple problem. I think it might come from a side effect of some issue and it reporteed as a lock problem, when it makes no sense - the .lock file is created. I delete it, restart, it is created again. There must be some silent error in the background. I have no idea where is the root problem...  
> **username_1**: The `.lock` file is supposed to be created by bitcoind which will then remove it during the shut down process.  The issue comes from the lock file being there when bitcoind is not running. You also need to remove the `.walletlock` file too.  
> **username_1**: After looking at your debug.log snippet more closely, your error is actually due to the `.walletlock` file.  

---

