1

This question already has an answer here:

I have a Desktop and Laptop.I have configured private blockchain on my Desktop(node1) and able to sync with it from Node2 Laptop.But I am not able to get connected to the contract deployed on Node 1 via a web page i created.

web3.version.getNetwork((err, netId) this function throws error Invalid JSON RPC response.

I am able to access the contract from web page located on my Desktop.

First Node geth --identity "Node1" --rpc --rpcport "8545" --rpccorsdomain "*" --datadir <data-path-1> --port "<defaultport>" --rpcapi "db,eth,net,web3,personal,miner" --networkid 123 console 2>> logfile_1

Second Node geth --identity "Node2" --rpcport "8545" --rpcaddr "xxx.xxx.xx.xx" --rpccorsdomain "*" --datadir <data-path-2> --port "<defaultport>" --rpcapi "db,eth,net,web3,personal,miner" --networkid 123 console 2>> logfile_2

marked as duplicate by Achala Dissanayake, Richard Horrocks, Briomkez, eth Nov 3 '18 at 12:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

web3.version.getNetwork((err, netId) this function throws error Invalid JSON RPC response.

Is this error thrown when you execute it via web3js on the browser? Could you try running this command on the Geth js console as well so we can try to isolate where the issue could be?

But I am not able to get connected to the contract deployed on Node 1 via a web page i created.

From what I can see, it is possible that your web3js is not even connecting to your node. Before trying to do anything else, you need to validate that the page can communicate with the node. Could you share the version of web3js that you are using? Also, if you could post a snippet of your javascript code it might help us to see something that might be wrong.

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