I have problem with invalid response to ethereum from BE NodeJS app. I got error like:

Error: Invalid JSON RPC response: ""

Below I'd attached my simple code for testing connection.

const Web3 = require("web3");
const web3 = new Web3(new Web3.providers.HttpProvider(providerUrl));
const contract_web3 = new web3.eth.Contract(abi, contractAddress);

console.log("Config Data: \n", providerUrl, "\n", config.privateKey, "\n", contractAddress);

contract_web3.methods.getDocuments().call((err, result) => {
    if (err) {
        // handle error here
        console.log("Test call error: ", err);
    else {
        console.log("Test call: ", result);

I'v readed about HDWalletProvider, but I havent dive in it yet.


  • 1
    What is the value of providerUrl, and do you have an Ethereum Node listening at this port/socket/connection? Commented Nov 29, 2019 at 11:27
  • Hello again, value of providerUrl is ropsten.infura.io/v3/my_project_id. Yes I have deployed smartcontract via remix ide to ropsten with my MetaMask account. Commented Nov 29, 2019 at 11:39
  • What is the value of contractAddress, and have you verified the contract at that address on etherscan (so that we can view its source code)? Commented Nov 29, 2019 at 12:25
  • Yes I had transaction on etherscan, with contract creation ropsten.etherscan.io/address/… Commented Nov 29, 2019 at 13:11

1 Answer 1


Ok. With this code the parts were errors might occur are very limited.

Make sure providerUrl has the correct value.

I hope you filled contractAddress correctly.

Abi is the bigger problem. Do a console.log of it. I would suggest a JSON.parse on the abi. This might fix the problem.

EDIT: What is your web3 version? Make sure not to use an outdated one.

  • Using an incorrect ABI could not possibly result in an Invalid JSON RPC response error. Commented Nov 29, 2019 at 21:35
  • Proxy could be a problem? I have proxy cert for npm, but maybe that nodeJS is prevented from making action by company proxy from app level. I will try behind proxy. Commented Dec 1, 2019 at 16:53
  • Without proxy it is working, but it seems to be connectet wrong.How can I connect ropsten contract deployed with remix ide + metamask? in code I have provateKey from metamask, contract address is correct, from etherscan copied. I have created project on infura but I thought it is something like gateway to ropsten. Commented Dec 1, 2019 at 17:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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