Bitcoin RPC ECONNREFUSED 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 }
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!