0

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 127.0.0.1:18332
at Object._errnoException (util.js:992:11)
at _exceptionWithHostPort (util.js:1014:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 18332 }

my configuration file is:

      testnet=1
      rpcuser=user
      rpcpassword=password
      rpcallowip=192.163.1.131

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 192.163.1.131 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 192.163.1.131? – JBaczuk Sep 4 '18 at 14:06
  • Yep. You're not connecting to 192.163.1.131 since a connection from 127.0.0.1 to 192.163.1.131 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 192.163.1.131 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 127.0.0.1! – 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.