I am developing a simple Voting dApp by following a tutorial. In this tutorial we are using npm install ethereumjs-testrpc web3 so that we can get the fake nodes of Ethereum.

For that i first created the object of web3 by using Web3 = require('web3') command in the Node.js command prob. After using the command i should get all the attributes of Web3. But i am only getting [Function: Web3].

After that i am using web3 to connect to the localhot:8545 by using web3 = new Web3("http://localhost:8545") in the Node.js command prob. To check that i am connected to localhost:8485 i am using web3.eth.getAccounts(console.log). I should get addresses as follows;


All i need is one of those addresses to proceed further. But i am getting an error which says that Connection refused or URL couldn't be resolved as follows;

Promise {
   Domain {
     domain: null,
      [Object: null prototype] {
        removeListener: [Function: updateExceptionCapture],
        newListener: [Function: updateExceptionCapture],
        error: [Function: debugDomainError] },
     _eventsCount: 3,
     _maxListeners: undefined,
     members: [],
     [Symbol(kWeak)]: WeakReference {} } }
> Error: Connection refused or URL couldn't be resolved: http://localhost:8545
    at XMLHttpRequest.request.onreadystatechange (D:\Notes\BCS\Semester 7\FYP\New One\node_modules\web3-providers\dist\web3-providers.cjs.js:759:22)
    at XMLHttpRequestEventTarget.dispatchEvent (D:\Notes\BCS\Semester 7\FYP\New One\node_modules\xhr2-cookies\dist\xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (D:\Notes\BCS\Semester 7\FYP\New One\node_modules\xhr2-cookies\dist\xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpRequestError (D:\Notes\BCS\Semester 7\FYP\New One\node_modules\xhr2-cookies\dist\xml-http-request.js:349:14)
    at ClientRequest.<anonymous> (D:\Notes\BCS\Semester 7\FYP\New One\node_modules\xhr2-cookies\dist\xml-http-request.js:252:61)
    at ClientRequest.emit (events.js:198:13)
    at ClientRequest.EventEmitter.emit (domain.js:448:20)
    at Socket.socketErrorListener (_http_client.js:392:9)
    at Socket.emit (events.js:198:13)
    at Socket.EventEmitter.emit (domain.js:448:20) null

I also check a relevant answer to my question in this stack exchange. But this answer is telling to use truffle instead of solving the above problem. And if comments of this answer are solving the above problem then they are perhaps solving it for actual web3 not for ethereumjs-testrpc web3.

I am using solidity and if you need the code i can edit my question.

  • Are you referring to the latest version of the tutorial? The latest version edited in Fed 2019 seems to use ganache-cli which is what testrpc is known as now. Even if you installed using npm install, you have to bring up the test RPC node before you can connect to that node.
    – Sanjay S B
    Jun 9, 2019 at 3:54
  • i used how i can bring up the test RPC node before you can connect to that node ? Jun 9, 2019 at 5:29
  • 2
    If you are using ganache, enter ganache-cli in another terminal and keep it running
    – Sanjay S B
    Jun 9, 2019 at 6:28
  • yes thank you, i just figured it out. Jun 9, 2019 at 6:29
  • Assuming you used npm install -g ganache-cli to install
    – Sanjay S B
    Jun 9, 2019 at 6:30

1 Answer 1


Try this,

  1. Open a new terminal and move to the folder chapter1 (following the tutorial).
  2. In the terminal run this node_modules/.bin/ganache-cli
  3. Open a new one terminal and test node, following the 2nd section of the tutorial.
  4. Don't close the terminal opened in the 1st step.

That works for me!

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.