ruimarinho / bitcoin-core

A modern Bitcoin Core REST and RPC client.
480 stars 188 forks source link

Unhandled rejection Error: connect ECONNREFUSED 127.0.0.1:18332 #28

Closed ghost closed 7 years ago

ghost commented 7 years ago

[root@localhost deploy]# node rpc.js
Unhandled rejection Error: connect ECONNREFUSED 127.0.0.1:18332 at Object.exports._errnoException (util.js:1018:11) at exports._exceptionWithHostPort (util.js:1041:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)

i have latest bitcoin core on linux machine., and latest node.js with latest bitcoin-core

`const Client = require('bitcoin-core'); const client = new Client({ network: 'regtest' });

client.getBlockByHash('0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206', { extension: 'json' }); `

ghost commented 7 years ago

what am i missing ? and why is that port says 18332 , where can i specify my port and username and password ?

thanks

ruimarinho commented 7 years ago

You can check the documentation for the arguments available for the Client constructor.

By default, the regtest network runs on port 18332 when using bitcoind. This is similar to the behaviour of bitcoin-cli when running in regtest mode.