Metamask doesn't connect to it's own localhost. I run a hardhat node from Mac. I know it's a known issue, but I've tried all available methods listed below. enter image description here

  1. I tried installing older versions of Metamask (initially 10.14.3)

  2. Tried adding other networks like Hardhat's 31337 . But it's a known Metamask bug List item

  3. Tried editing Metamask default localhost, but it throws error at it's default chain ID lol enter image description here

  4. Tried setting Hardhat chain ID to 1337

  • What client are you running on localhost? Geth, ganache, besu, etc. Are you connecting from windows, linux, mac?
    – Ismael
    Commented May 17, 2022 at 7:00
  • @Ismael I'm running a hardhat localhost network from mac Commented May 17, 2022 at 10:45
  • Are you sure it is running at the configure port? Perhaps you might be affected by this hardhat.org/metamask-issue.html.
    – Ismael
    Commented May 17, 2022 at 14:31

1 Answer 1


The solution to this problem is to pass the chainId:1337 directly in the hardhat.config.js file.



// The next line is part of the sample project, you don't need it in your
// project. It imports a Hardhat task definition, that can be used for
// testing the frontend.

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.9",
  networks: {
    hardhat: {
      chainId: 1337 // We set 1337 to make interacting with MetaMask simpler

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.