I am just trying to create a HD wallet with web3 and truffle to make receive some ethers. I have installed both of these packages with npm. Inside a node console, I am trying to run this to get a private/public key :

Bip39 = require("bip39");
const mnemonicPhrase = Bip39.generateMnemonic();

const HDWalletProvider = require("@truffle/hdwallet-provider");
Web3 = require('web3');

provider = new HDWalletProvider({
  mnemonic: mnemonicPhrase,
  providerOrUrl: "http://localhost:8545",
  numberOfAddresses: 1,
  shareNonce: true,
  derivationPath: "m/44'/0'/0'/0/"

const web3 = new Web3(provider);

I am running one piece of code after another and just after I run the provider = new HDWalletProvider(), I get this error:

Error: PollingBlockTracker - encountered an error while attempting to update latest block:
Error: connect ECONNREFUSED
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)
    at TCPConnectWrap.callbackTrampoline (internal/async_hooks.js:131:14)
    at PollingBlockTracker._performSync (C:\Users\Me\node_modules\eth-block-tracker\src\polling.js:51:24)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {

Some people mentioning this error are fixing it with something like testrpc, geth --rpc that is apparently used to send the transaction on the ethereum network, but I don't want to do that, I just need to retrieve the private/public key in web3js. I really don't understand what I need to do to fix this.

1 Answer 1


I had a similar error. I solved it by changing the IP address I had been trying to connect to.

from "" to ""

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.