I was trying to connect my bitcoin network with an RPC, it worked well with my localhost however when I try to connect it remotely from another host it returned the following error

   { Error: connect ECONNREFUSED
at Object._errnoException (util.js:992:11)
at _exceptionWithHostPort (util.js:1014:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
syscall: 'connect',
address: '',
port: 18332 }

my configuration file is:


the code used for calling:

  var bitcoin = require('bitcoin');
  var client = new bitcoin.Client({
  host: 'localhost',
  port: 18332,
  user: 'user',
  pass: 'password'


 client.getDifficulty(function(err, difficulty) {
 if (err) {
  return console.error(err);

 console.log('Difficulty: ' + difficulty);

remote IP is and I'm using a VirtualBox VM as the host machine

similar question: Bitcoin RPC ECONNREFUSED

but not worked for me

  • 1
    your code still says localhost, shouldn't that be – JBaczuk Sep 4 '18 at 14:06
  • Yep. You're not connecting to since a connection from to is (pretty much) impossible. – David Schwartz Sep 5 '18 at 2:00
  • @DavidSchwartz sorry, I didn't get that. can you please make it more clear. I want to connect my pc with IP address to the bitcoin node..what should I do? – Akshay Dev Sep 5 '18 at 4:06
  • On that machine, you should try to connect to the bitcoin node. I don't know what its IP address is, but it's certainly not! – David Schwartz Sep 5 '18 at 4:46
  • @DavidSchwartz actually, I want to allow my pc to make JSON RPC call from the bitcoin node running on the virtual machine. any solution? – Akshay Dev Sep 5 '18 at 7:08

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.