Metamask Not Connecting to Localhost 8545
I Was Trying to Follow a Tutorial from Devto. Io and to Send Transactions to the Smart Contract, I Would Need to Connect My Metamask Wallet Using One of the...
I was trying to follow a tutorial from devto.io and to send transactions to the smart contract, I would need to connect my MetaMask wallet using one of the accounts created when I ran npx hardhat node command.
To do so, I opened MetaMask and updated the network to be Localhost 8545, but Metamask didn't connect to it and showed errors like the following screenshot.
3 Answers
I think that you probably interrupted the node you launched when you typped :
npx hardhat node
You should keep it running, open another terminal for the rest of the tutorial. Also you could check the output of this command. Is it indicating something else than ? :
Started HTTP and WebSocket JSON-RPC server at
You probably have a IPv6 address that is not listening on that port.
e.g.
$ ping localhost
PING localhost.localdomain (::1)...
either remove that line from /etc/hosts (e.g. ::1 localhost.localdomain localhost) or point ethermask to 127.0.0.1 instead of localhost
The error is most simple that you probably think, the default chain id for test networks in metamask is not the same as the hardhat chain id, you should go to metamask, then config, networks, localhost and change chain id to 31337