I'm using the web3 API and i'm defining the web3 instance, setting a provider like this:

if (typeof web3 !== 'undefined') {
  web3 = new Web3(web3.currentProvider);
} else {
  // set the provider you want from Web3.providers
  web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

But alot of times i have problems with connection, i'm working whit the Ropsten testnet and i'm only using this for test and to learn about Dapps. What is a good alternative for solve this problems of connection? Maybe infura? or exist there some tips to solve it?

  • you could use solidity browser to check the connection with your local node if it connects all is ok otherwise check you local settings (node port, is rpc on, firewall etc..)
    – Badr Bellaj
    Jul 6, 2017 at 10:23
  • the connection maybe is not the problem cause i can work, but this last month some time i can't connect with it, i obtained errors like "Lost connection" or "not found the conenction" i wait a 5 min and it turn on again and works again, but i prefer don't stay waiting...
    – Gawey
    Jul 6, 2017 at 10:31

1 Answer 1


If you are using this for learning and testing purposes, I'd suggest using testrpc which simulates Ethereum node. It's fast and runs locally so you won't encounter any connection problems at all.

  • With testrpc i can check later the transactions in etherscan.io ? I don't knwo how it works...
    – Gawey
    Jul 6, 2017 at 10:27
  • No, it's a testing tool that runs locally and transactions aren't submitted to a public blockchain. I'd recommend starting with testrpc to develop, test and refactor your contracts and only after they are mature enough publish to public blockchian. Infura it's a good choice for connecting to a public node. Also geth in light mode or parity with pruning are syncing extremely fast. This approach will local testing first will save you a lot of time. Jul 6, 2017 at 11:15
  • Ummm ok, and how can i know if the contact functions works well? For example one transaction of eth or somethign similar liek thsi with the testrpc.
    – Gawey
    Jul 14, 2017 at 10:51
  • First, you will have logs from testrpc in console reporting transaction status and consumed gas (similar to what you can get from testrpc). Second, you may write tests to query if the contract states were updated correctly. Jul 14, 2017 at 12:08
  • So the contracts can store things, for example a state change, like in the RosptenTest net?
    – Gawey
    Jul 14, 2017 at 12:11

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.