Metamask: MetaMask does not pick up Hardhat accounts on port 8545
MetaMask Not Picking Hardhat Accounts on Port 8545 in Firefox
As a developer using Web3 and Solidity-based contracts, you’re likely accustomed to working with MetaMask. However, when connecting to local development environments like Hardhat, you might encounter issues that prevent the wallet from picking up accounts correctly. Today, we’ll explore one such issue: MetaMask not selecting hardhat accounts on Port 8545 in Firefox.
The Issue
When you connect your Hardhat node to a test network (localhost:8545) using MetaMask’s Localhost Test Network option, it seems like the wallet should automatically select the correct account from the list. However, this isn’t always the case. In some instances, the first account selected is entirely different from the actual accounts you’ve listed.
The Solution
To resolve this issue, we’ll investigate possible causes and provide a step-by-step solution to troubleshoot and fix the problem.
Cause 1: Incorrect Account Selection
One potential cause of this issue is that MetaMask’s Localhost Test Network configuration doesn’t match your Hardhat node’s IP address ( If the wallet selects an incorrect account, it will not pick up the correct one from the list.
To verify this:
- Open MetaMask on Firefox and go to
Network >
Advanced Settings.
- Check if “Auto Select Account” is enabled and set to match your Hardhat node’s IP address (
Cause 2: Incorrect Wallet Configuration
Another potential cause of this issue is incorrect wallet configuration on your Hardhat node.
You solve:
- Ensure you’re running a recent version of the MetaMask extension.
- Check if you’ve updated your
hardhat.config.js
file to include the correct IP address for your local development environment (e.g.,
Troubleshooting Steps
To troubleshoot and resolve the issue, try the following:
Step 1: Verify Wallet Configuration
– Ensure MetaMask is installed on your browser.
– Check if you’ve updated your Hardhat node to include the correct IP address.
Step 2: Adjust Localhost Test Network
– Go back to your MetaMask configuration.
– Change the “Test Networks” to match your hardhat node’s IP address (
– Save and restart MetaMask.
Step 3: Review Hardhat Node Configuration
– In your hardhat.config.js
file, check for any incorrect configurations that might be causing the issue.
– Ensure that you’re using the correct network settings and IP address (
Conclusion
If you’ve tried the troubleshooting steps above and are still experiencing issues with MetaMask selecting hardhat accounts on Port 8545, it’s likely due to an incorrect wallet configuration or a mismatch between your Hardhat node’s IP address and the Localhost Test Network setting.
By following these steps, you should be able to resolve this issue and ensure that MetaMask is picking up the correct account from the list when connecting to your local development environment using Hardhat.