user77986: Trying to RPC my local active Bitcoin Full Node, but getting ECONNREFUSED on client.getBalance. Am I missing additional configuration? Is there a better RPC wrapper to use? Any advice or working examples would be greatly appreciated!
CODE:
var bitcoin=require("bitcoin");

var client = new bitcoin.Client({
  host: 'localhost',
  port: 8332,
  user: 'username',
  pass: 'password',
  timeout: 30000
});

client.getBalance('*', 6, function(err, balance, resHeaders) {
  if (err) return console.log(err);
  console.log('Balance:', balance);
});

CONFIGURATION FILE:
server=1
rpcuser=username
rpcpassword=password
rpcport=8332
rpcallowip=127.0.0.1

ERROR:
{ Error: connect ECONNREFUSED 127.0.0.1:8332
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 8332 }


user77986: Here is the solution that worked for me...

bictcoin.conf

txindex=1
server=1
rpcuser=username
rpcpassword=password
port=8444
rpcport=8332
rpcbind=127.0.0.1
rpcallowip=127.0.0.1

Bitcoin Daemon must be running
DOS CMD: netstat -a -n  must show listening for both ports 8444 and 8332

Good luck!

77986: <p>Trying to RPC my local active Bitcoin Full Node, but getting ECONNREFUSED on client.getBalance. Am I missing additional configuration? Is there a better RPC wrapper to use? Any advice or working examples would be greatly appreciated!</p>

<p>CODE:</p>

<pre><code>var bitcoin=require("bitcoin");

var client = new bitcoin.Client({
  host: 'localhost',
  port: 8332,
  user: 'username',
  pass: 'password',
  timeout: 30000
});

client.getBalance('*', 6, function(err, balance, resHeaders) {
  if (err) return console.log(err);
  console.log('Balance:', balance);
});
</code></pre>

<p>CONFIGURATION FILE:</p>

<pre><code>server=1
rpcuser=username
rpcpassword=password
rpcport=8332
rpcallowip=127.0.0.1
</code></pre>

<p>ERROR:</p>

<pre><code>{ Error: connect ECONNREFUSED 127.0.0.1:8332
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 8332 }
</code></pre>
 77986: <p>Here is the solution that worked for me...</p>

<ol>
<li>bictcoin.conf</li>
</ol>

<p>txindex=1
server=1
rpcuser=username
rpcpassword=password
port=8444
rpcport=8332
rpcbind=127.0.0.1
rpcallowip=127.0.0.1</p>

<ol start="2">
<li><p>Bitcoin Daemon must be running</p></li>
<li><p>DOS CMD: netstat -a -n  must show listening for both ports 8444 and 8332</p></li>
</ol>

<p>Good luck!</p>
