3

I am running a local ganache-cli and my metamask in my browser just keeps saying:

Oops! Something went wrong.

enter image description here

Here are the network details:

name: Localhost
RPC URL: http://localhost:8545
Chain ID: 1337

This started happening literally today, never had issues with it before. I don't think I changed any settings that would have affected this. I was just testing smart contracts locally like I normally do.

And my ganche-cli reflects this. I even make the JSON-RPC call for chainId, and this is correct.

Here is what I've tried:

  1. Switching browsers (brave -> chrome)
  2. Changing ports on both the ganache-cli, UI, and metamask
  3. Changing RPC_URL (to localhost, 0.0.0.0...) on both the ganache-cli, UI, and metamask
  4. Using the ganache app
  5. Uninstalling and reinstalling browsers
  6. Uninstalling and reinstalling metamask
  7. Turning computer off and on again
  8. Resetting account in the advanced config

I'm losing my mind. I am able to deploy contracts to the ganache chain via the command line.

Here is what else I've looked at: Metamask not connecting to localhost http://asifwaquar.com/connect-metamask-to-localhost/ https://github.com/MetaMask/metamask-extension/issues

Patrick Collins
  • 11,186
  • 5
  • 44
  • 97
  • 1
    Do you have other extension that may cause problems? I've the same configuration with Metamask on Firefox and Chrome without issues. Sometimes "reset account" in the Advanced menu fixed some odd issues with Metamask and ganache. – Ismael Mar 06 '21 at 21:03
  • Yep :( Tried that too. – Patrick Collins Mar 06 '21 at 21:08
  • Just for reference I've just tested with Ganache CLI v6.12.1 (ganache-core: 2.13.1) under node v12.20.0 with Metamask v9.1.1 and it worked. – Ismael Mar 06 '21 at 21:20
  • 1
    my ganache get always 5777 as network id, can you change it to that – Majd TL Mar 06 '21 at 21:54
  • 1
    Yep :( I get The endpoint returned a different chain ID: 1337 – Patrick Collins Mar 06 '21 at 22:01
  • What operating system are you using? Are you sure the localhost:8545 is reachable?

    Start with: $ ganache-cli --networkId 4711

    Check with: $ curl -X POST --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":67}' localhost:8545 {"id":67,"jsonrpc":"2.0","result":"4711"}

    – Markus Sprunck Mar 07 '21 at 11:29
  • MacOS. Yes, I was able to make JSON-RPC calls with ease. It returned the proper chainId – Patrick Collins Mar 07 '21 at 18:17
  • I'm assuming if we find out what API call metamask is making, we can probably test that and see what's going wrong. – Patrick Collins Mar 07 '21 at 18:21

3 Answers3

2

Got it.

Both my Brave browser and Google Chrome were having issues. I tested then on firefox and it worked fine. A reinstall of Google Chrome fixed the issue for Chrome. A reinstall of Brave did not fix it.

Looks like it's an issue with Brave Browser. Thanks all.

Patrick Collins
  • 11,186
  • 5
  • 44
  • 97
1

Ensure that you can really access your ganache-cli on localhost:8545 and the network id is 1337. Metamask asks for 'net_version' when connecting to the blockchain.

  1. Start Ganache with:
$  ganache-cli --networkId 1337
  1. Check with:
$ curl -X POST --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":67}' localhost:8545

expected result:

{"id":67,"jsonrpc":"2.0","result":"1337"}
Markus Sprunck
  • 448
  • 4
  • 14
0

I had the same issue that metamask could not connect to my page. But in my case, I ran truffle migrate --reset and got back zsh: command not found: truffle and thus after npm install -g truffle, I ran truffle migrate and refreshed my page and it worked.

Yves Boutellier
  • 402
  • 4
  • 12