How to Debug Metamask Errors? (Developer Edition)

Aliasgar Merchant
4 min readDec 8, 2020

Let’s accept it — Blockchain Developers (the cool solidity fans) have faced error from Metamask at some point or the other. Sometimes its easy to just reset the bad boy, but sometimes developers spend hours together debugging metamask.

In this article, I will talk about most common Metamask errors, how can you debug / solve them and how can you reset your entire slate (development environment) to have a fresh new canvas to work upon.

Metamask Lifecycle

Metamask lifecycle
  1. Step 1: Before the Dapp is loaded into the browser, the user needs to select the account in Metamask.
  2. Step 2: Front-end of the Dapp is loaded in browser & metamask is injected in the webpage; and javascript code starts to execute.
  3. Step 3: Metamask prompts the user to allow Dapp to access its address.
  4. Step 4: Rest of Javascript code of Dapp is loaded when the setup of various event handlers attached to forms is completed.
  5. Step 5: User click on send button to send transaction; Metamask prompts the user for confirmation and transaction is sent to Ethereum network.

Metamask Error

Localhost Error

While developing a Dapp, for testing purposes, a local account with Ganache is used. When Metamask is connected to localhost 9545 and it throws error you can try:

Restarting Ganache, Restart Browser or restart computer. Also check Metamask configuration and prefer using “127.0.0.1" instead of local host.

Another parameter recently added is Chain ID. I tried using hexadecimal number, it refused — but provides a number to use.

Wrong address error

When Dapp is loaded, Metamask is injected into the Javascript code and then Metamask prompts user for access of account address.

--

--

Aliasgar Merchant

Novice astrophysicist in Cosmos. Building the next revolution of BFT consensus with CometBFT. I write about Blockchain related concepts.