I'm using these instructions from etherchain. Here's a similar question(seems like duplicate, but it's not). The solution provided there doesn't work for me, because I don't have a local ethereum client to connect to. I want to use one provided by Etherchain.

const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider("http://rpc.ethapi.org:8545"));
web3.eth.getBlock("latest", (error, result) => {
  console.log('error:', error);
  console.log('results', result);


Error: Invalid JSON RPC response: ""
   at Object.InvalidResponse (/home/manid/Рабочий стол/Pogovorim/NODE_SERVER/node_modules/web3/lib/web3/errors.js:35:16)
    at XMLHttpRequest.request.onreadystatechange (/home/manid/Рабочий стол/Pogovorim/NODE_SERVER/node_modules/web3/lib/web3/httpprovider.js:116:32)
    at XMLHttpRequestEventTarget.dispatchEvent (/home/manid/Рабочий стол/Pogovorim/NODE_SERVER/node_modules/xhr2/lib/xhr2.js:64:18)
    at XMLHttpRequest._setReadyState (/home/manid/Рабочий стол/Pogovorim/NODE_SERVER/node_modules/xhr2/lib/xhr2.js:354:12)
    at XMLHttpRequest._onHttpRequestError (/home/manid/Рабочий стол/Pogovorim/NODE_SERVER/node_modules/xhr2/lib/xhr2.js:544:12)
    at ClientRequest.<anonymous> (/home/manid/Рабочий стол/Pogovorim/NODE_SERVER/node_modules/xhr2/lib/xhr2.js:414:24)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at Socket.socketErrorListener (_http_client.js:309:9)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at emitErrorNT (net.js:1281:8)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

What am I missing?

  • 1
    Your solution is probably in here. ethereum.stackexchange.com/questions/2080/…
    – tayvano
    Jan 10 '17 at 11:45
  • @tayvano, thank you! That solution doesn't work for me, because I'm connecting to a remote host and the solution provided there is for connection to geth node running on local machine.
    – manidos
    Jan 10 '17 at 12:10

I've replaced

const web3 = new Web3(new Web3.providers.HttpProvider("http://rpc.ethapi.org:8545"));


const web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/TOKEN"));

and everything works.

This https://ropsten.infura.io/TOKEN was given to me after registration on infura.io

  • 1
    Seems like rpc.ethapi.org is down: isup.me/rpc.ethapi.org Jan 10 '17 at 14:05
  • I have tried what you suggested to connect to ropsten but i get an error Error: Invalid JSON RPC response: "" at Object.module.exports.InvalidResponse (/Blockchain/node_modules/web3/lib/web3/errors.js:35:16) at HttpProvider.send (/Blockchain/node_modules/web3/lib/web3/httpprovider.js:91:22) at RequestManager.send (/Blockchain/node_modules/web3/lib/web3/requestmanager.js:58:32) at Eth.send [as sendTransaction] (/Blockchain/node_modules/web3/lib/web3/method.js:145:58) at SolidityFunction.sendTransaction (/Blockchain/node_modules/web3/lib/web3/function.js:148:26) at SolidityFunction.execute (/Blo Jun 15 '17 at 14:20
  • i think u mean ropsten.infura.io/[API_KEY]? to avoid the confusion to token smart contract....
    – Richard Fu
    Jun 21 '18 at 0:53

You should be careful using Infura because it can relay you incorrect information. Infura is architected with multiple nodes behind a load balancer. All of these nodes are not in sync, so you can receive information from nodes that contain stale blocks or nodes that are not synced with the most recent block.

We used to use Infura, which was great because it is free, however, it resulted in many hours of engineering work for us as we had to debug responses with inconsistent data. We switched to Alchemy, and we wish we had switched to it sooner. It is a paid service, however, it is worth every penny.

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.