Connecting to your Bitcoin node from another computer

By | December 2, 2015

If you are running a Bitcoin node on one of your servers that has an internal IP of 192.168.1.x then you’ll know you can hit the API using localhost or 127.0.0.1

But what if you want to make a JSON-RPC call from another computer from with your local network?

If it is not configured, you’ll end up with something like this:

Screenshot from 2015-12-02 06:36:00

What you need to do is add your IP to the bitcoin.conf file:

rpcuser=xxx
rpcpassword=xxxx
server=1
rpcallowip=192.168.1.8

Note that server=1 tells the server/node to accept or not accept JSON-RPC commands. It is not strictly required depending on if you run in headless (command line) mode or in qt (graphical) mode. It doesn’t hurt to include it as a default anyway.

You should then get this:
curl to node

Which indicates that you have connectivity. A proper example curl command would be:

curl -X POST -H "Content-Type: text/plain" 192.168.1.14:8332 -u xxx:xxx --data '{"method": "getblockhash","params": [0],"id": "foo"}'

This should return:

result

which is is the genesis block.

For more information, check out http://manpages.ubuntu.com/manpages/precise/man5/bitcoin.conf.5.html and read the JSON-RPC OPTIONS section.

The document notes that you can also use wild card characters as in rpcallowip=192.168.1.*

Leave a Reply

Your email address will not be published.