0

I am using web3js, I've set up an ethereum node in my network in a laptop via mist, now I'd like to run a web3js script that uses that node as provider;

var PROVIDER = "192.168.1.40:8545" // I've also tried 30303
var web3 = new Web3(new Web3.providers.HttpProvider(PROVIDER))
web3.eth.getBalance(TARGET_WALLET_ADDRESS);

This throws error

CONNECTION ERROR: Couldn't connect to node 192.168.1.40:8545.

Port 30303 shows as open, while 8545 shows as filtered. Is there any configuration step I'm missing? I'm supposed to use port 8545 right?

Also, I have a question:

  • Can I use the node if it's not fully synced? By use I mean get balance of an account and do transactions

Thank you

1

You should allways use localhost or 127.0.0.1 when conecting to local nodes.

You should be able to use a node while syncing, but the result will be outdated.

  • Thanks for the answer. Can you elaborate why I should connect to localhost? it should be almost the same right? – Victor Feb 6 '18 at 20:40
  • No, localhost/127.0.0.1 doesn't exit the machine, so it won't matter which ports are open to the outside – Hari GTT Psicolabis Feb 6 '18 at 21:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.