5

I am trying to connect Metamask to ganache by creating a custom RPC with the following details:

New RPC URL: HTTP://127.0.0.1:7545

Chain Id: 5777

But I keep getting the error message The endpoint returned a different chain ID: 0x539

1
  • still not sure why network ID and chain ID are different for ganache most of the time they are the same - see my answer below – James Daly Nov 22 '20 at 21:28
2

You either need to update your custom MetaMask Network to match the default chainId returned by Ganache (which is 1337) or, if you are using ganache-cli use a command like ganache-cli --port 7545 --chainId 5777 to change the chainId to 5777.

If you are using Ganache GUI you can't change the chainId, so you'll need to change it in MetaMask instead.

1

Try locking the account and when you are asked to sign in again use the option import wallet using mnemonic or seed phrase copy that from ganache and should be good to go

1

You appear to be using Ganache GUI, so this may not directly help you, but I can at least provide an explanation.

With Metamask 8.1.3 and above, local Ganache-cli blockchains began breaking due to a mismatching ChainId.

Fixing with the CLI is a matter of:

  • Upgrade ganache-cli to v.6.11.0 or above, then start it with the --chainId flag, for example: ganache-cli --deterministic -i 5777 --chainId 5777
  • Then setup your custom RPC in Metamask with the same chainId.

You may be able to simply upgrade your Ganache GUI version and achieve the same thing.

1

I was having the same error and locking the metamask and using Ganache mnemonic worked for me.

1
  • Thanks for answering! Could you clarify what you mean by "locking Metamask"? – The Renaissance Dec 7 '20 at 8:04

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.