<p>I fixed it by simply instantiating the fullnode object outside of the async block</p>

<pre><code>var full = new bcoin.node.FullNode({
   network: "testnet",
   httpPort: 18332,
   prefix: '~/.bcoin/testnet',
   httpHost: '127.0.0.1',
   bip37: true,
   listen: true,
   workers: true,
   passphrase: "secret",
   logLevel: "info",
   loader: require
});

(async () =&gt; {
   //do stuff
))();
</code></pre>

CC BY-SA 3.0
2017-11-28T23:12:02.763Z
2017-11-28T23:12:02.763Z
arshbot
<pre><code>bcoin.network.get().toString()
</code></pre>

<p>returns <code>main</code> which is not a valid network string, it should be one of <code>mainnet</code> <code>testnet</code> <code>simnet</code> or <code>regtest</code>.</p>

CC BY-SA 3.0
2017-12-03T03:11:03.890Z
Even changing the network to `testnet` didn't work
arshbot
CC BY-SA 3.0
2017-11-30T09:16:50.003Z
2017-11-30T09:16:50.003Z
tuxcanfly
<p>Getting an error Unknown Network running a bcoin node, but I'm not sure what's causing it since I'm defining the network very quickly.</p>

<p>Error Message:</p>

<pre><code>(node:10579) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Unknown network.
(node:10579) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
</code></pre>

<p>Here is the bcoin script</p>

<pre><code>var bcoin = require('bcoin').set('testnet');

(async () =&gt; {
  var full = new bcoin.node.FullNode({
    network: bcoin.network.get().toString(),
    httpPort: 18332,
    httpHost: '127.0.0.1',
    bip37: true,
    listen: true,
    passphrase: "secret",
    logLevel: "info",
    loader: require
  });

  if (!full.config.bool('no-wallet') &amp;&amp; !full.has('walletdb')) {
    const plugin = require('/Users/&lt;user&gt;/Projects/bcoin/lib/wallet/plugin');
    full.use(plugin);
  }
  await full.open();


  setUpWalletWatcher(full.pool, full.walletdb);
  await full.connect();
  await full.http.open();

  full.startSync();

})();
</code></pre>

<node.js><bcoin>
Error: Unknown network starting a bcoin node
arshbot
# Error: Unknown network starting a bcoin node

(Asked by: username_0 on 2017-11-28)

Getting an error Unknown Network running a bcoin node, but I'm not sure what's causing it since I'm defining the network very quickly.
Error Message:
(node:10579) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Unknown network.
(node:10579) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Here is the bcoin script
var bcoin = require('bcoin').set('testnet');

(async () => {
  var full = new bcoin.node.FullNode({
    network: bcoin.network.get().toString(),
    httpPort: 18332,
    httpHost: '127.0.0.1',
    bip37: true,
    listen: true,
    passphrase: "secret",
    logLevel: "info",
    loader: require
  });

  if (!full.config.bool('no-wallet') && !full.has('walletdb')) {
    const plugin = require('/Users//Projects/bcoin/lib/wallet/plugin');
    full.use(plugin);
  }
  await full.open();


  setUpWalletWatcher(full.pool, full.walletdb);
  await full.connect();
  await full.http.open();

  full.startSync();

})();

**Tags:** node.js, bcoin


---

## 2 answers

### Answer by username_0 on 2017-11-28. Score: 0 | Accepted answer

I fixed it by simply instantiating the fullnode object outside of the async block
var full = new bcoin.node.FullNode({
   network: "testnet",
   httpPort: 18332,
   prefix: '~/.bcoin/testnet',
   httpHost: '127.0.0.1',
   bip37: true,
   listen: true,
   workers: true,
   passphrase: "secret",
   logLevel: "info",
   loader: require
});

(async () => {
   //do stuff
))();


---

### Answer by username_1 on 2017-11-30. Score: 1

bcoin.network.get().toString()

returns main which is not a valid network string, it should be one of mainnet testnet simnet or regtest.

> **Comments:**
> **username_0**: Even changing the network to `testnet` didn't work  

---

