<p>You must be running <code>testnet</code> in another shell or some other script that has opened the chain database.</p>

<p>Whenever you open chain database it gets locked so only one process is in charge of it.</p>

<p><code>lsof -d txt | grep filename</code> You could try this one to locate process holding FD for it.</p>

CC BY-SA 3.0
2017-08-10T17:30:23.620Z
This worked! Thanks. I was able to grep for bcoin with `lsof -d txt | grep bcoin` and then `kill [PID]`. I guess this would only work if the running process is bcoin and not a custom script, but good to know at least for checking possibilities. Thanks!
Bucko
CC BY-SA 3.0
2017-08-10T17:08:16.967Z
2017-08-10T17:22:15.717Z
2017-08-10T17:22:15.717Z
Node
<p>I'm trying to run a script that retrieves transactions from the blockchain. When I run the script though I get the following error:</p>

<p><code>Error: IO error: lock /home/bucko/.bcoin/testnet/chain.ldb/LOCK: Resource temporarily unavailable</code></p>

<p>Here is the JS I'm trying to run:</p>

<pre><code>'use strict';

const path = require('path');
const bcoin = require('../..');
const Chain = bcoin.chain;
const Logger = bcoin.logger;
const util = bcoin.util;

const HOME = process.env.HOME;

// Setup logger to see what's Bcoin doing.
const logger = new Logger({
  level: 'debug'
});

// Create chain for testnet, specify chain directory
const chain = new Chain({
  logger: logger,
  network: 'testnet',
  db: 'leveldb',
  prefix: path.join(HOME, '.bcoin/testnet'),
  indexTX: true,
  indexAddress: true
});

(async () =&gt; {
  await logger.open();
  await chain.open();

  const entry = await chain.getEntry(50000);
  console.log('Block at 50k:', entry);

  // eslint-disable-next-line max-len
  const txhash = '7f5990b008a2d0fc006d13b15e25d05ff30fadab656d49a5c6afea0e0d0b458c';
  const txmeta = await chain.db.getMeta(util.revHex(txhash));
  console.log(`Tx with hash ${txhash}:`, txmeta);

})().catch((err) =&gt; {
  console.error(err.stack);
  process.exit(1);
});
</code></pre>

<blockchain><node.js><bcoin>
bcoin chainldb Resource Temporarily unavailable
Bucko
# bcoin chainldb Resource Temporarily unavailable

(Asked by: username_0 on 2017-08-10)

I'm trying to run a script that retrieves transactions from the blockchain. When I run the script though I get the following error:

`Error: IO error: lock /home/username_0/.bcoin/testnet/chain.ldb/LOCK: Resource temporarily unavailable`

Here is the JS I'm trying to run:

```
'use strict';

const path = require('path');
const bcoin = require('../..');
const Chain = bcoin.chain;
const Logger = bcoin.logger;
const util = bcoin.util;

const HOME = process.env.HOME;

// Setup logger to see what's Bcoin doing.
const logger = new Logger({
  level: 'debug'
});

// Create chain for testnet, specify chain directory
const chain = new Chain({
  logger: logger,
  network: 'testnet',
  db: 'leveldb',
  prefix: path.join(HOME, '.bcoin/testnet'),
  indexTX: true,
  indexAddress: true
});

(async () => {
  await logger.open();
  await chain.open();

  const entry = await chain.getEntry(50000);
  console.log('Block at 50k:', entry);

  // eslint-disable-next-line max-len
  const txhash = '7f5990b008a2d0fc006d13b15e25d05ff30fadab656d49a5c6afea0e0d0b458c';
  const txmeta = await chain.db.getMeta(util.revHex(txhash));
  console.log(`Tx with hash ${txhash}:`, txmeta);

})().catch((err) => {
  console.error(err.stack);
  process.exit(1);
});

```

**Tags:** blockchain, node.js, bcoin


---

## 1 answers

### Answer by username_1 on 2017-08-10. Score: 2 | Accepted answer

You must be running `testnet` in another shell or some other script that has opened the chain database.

Whenever you open chain database it gets locked so only one process is in charge of it.

`lsof -d txt | grep filename` You could try this one to locate process holding FD for it.

> **Comments:**
> **username_0**: This worked! Thanks. I was able to grep for bcoin with `lsof -d txt | grep bcoin` and then `kill [PID]`. I guess this would only work if the running process is bcoin and not a custom script, but good to know at least for checking possibilities. Thanks!  

---

