I ran a hardhat node just fine using npx hardhat node, but after I shut it down and restarted it, whenever I try to deploy something on the chain, I get the following error:


  Received invalid block tag 87. Latest block number is 0

How to fix this?

  • use ganache :) until you find a solution for this error
    – Majd TL
    Sep 10 at 14:20
  • ganache won't work ProviderError: Method hardhat_impersonateAccount not supported. #crying
    – Nat
    Sep 24 at 15:39
  • made a gitub post github.com/nomiclabs/hardhat/issues/1906, there's an issue I included which may be related
    – Nat
    Sep 24 at 15:52

Try changing the network in Metamask and then switching back to the network you are using to connect to the hardhat node (probably the Localhost 8545 network).

There seems to be some sort of cache with the highest block number known, and it tries to keep using that value after the network is reset. This might be a Metamask issue, or maybe something in the dapp like the ethers.js provider.

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.