New RPC Url:
ChainId: 31337
Could not fetch chain ID. Is your RPC URL correct?

I am trying to run a local blockchain using hardhat but during configuration it is showing this error. I googled it and got this as the RPC url. Thanks for helping!

  • Do you have a hardhat node running in the background while trying to access it?
    – Mouradif
    Aug 26, 2023 at 19:50

1 Answer 1


Add this to your hardhat.config.js and then do npx hardhat node. After that it should not show any error in your metamask.

networks: { hardhat: { chainId: 1337 } }

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.