I want to connect local ethereum network to metamask , it says that it need chain id but when i entered the chain id for local node it shows the error "Could not fetch chain ID. Is your RPC URL correct?" I am running geth consol on local pc. What should i do ? thank you
-
Can you paste the command you are using to start geth? – Franco Victorio Dec 16 '20 at 18:29
-
geth --port 30303 --networkid 1234 --nodiscover --datadir=$ethereum_home/paradox --rpc --rpcport 8545 --rpccorsdomain "http://localhost:8000" --allow-insecure-unlock --ethstats paradox:s3cr3t@localhost:3000 --rpcapi "eth,net,web3,personal,miner" – Prasanna Desai Dec 17 '20 at 04:47
-
I tried --rpcorsdomain "*" and also tried to set network id and chain id same. But did not work – Prasanna Desai Dec 17 '20 at 08:19
-
You are starting that local node, and then trying to connect to it from MetaMask? And MetaMask gives you that error? – Franco Victorio Dec 17 '20 at 12:48
-
That is right , I started node and deployed contract on local ethereum , then I went to the front end of that contract to make a transaction and for that transaction to complete i need metamask. so I added custom RPC and it was long before the metamask update back then it worked very well but now it is asking for ChainId and when i am entering , it gives error. I tried both Hex and Decimal value of chainId – Prasanna Desai Dec 17 '20 at 16:17
-
Did anybody find a solution? I'm running into the same problem. I can connect from my Windows 10 to the Ethereum node running under WSL with geth (running under Windows) without problems, but MetaMask shows the error "Could not fetch chain ID. Is your RPC URL correct?" – Gorgsenegger May 20 '21 at 06:14
5 Answers
You seem to have started geth with networkid 1234 and then are trying to reach it on id 4224.
Try connecting it to 1234 (or set networkid to 4224 in geth)
- 176
- 5
You have to change the localhost to a loopback ip address with the port e.g HTTP://127.0.0.1:7545 that is whatever your Ganache RPC SERVER IS
If you happen to be using Ganache in combination with WSL, then you may have to adjust your settings accordingly:
- In Ganache, go to
Settings=>Server - In the
HOSTNAMEdropdown box, select the network interface with(WSL)at the end, e.g.172.29.64.1 - vEthernet (WSL) - Click on the
SAVE AND RESTARTbutton
Change your truffle-config.js to reflect the changed IP address, e.g.:
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// for more about customizing your Truffle configuration!
networks: {
development: {
host: "172.29.64.1",
port: 7545,
network_id: "*" // Match any network id
},
develop: {
port: 8545
}
}
};
In Metamask, use the following settings for the Custom RPC:
- New RPC URL
http://172.29.64.1:7545 - Chain ID
1337
The Chain ID must be set in Metamask and is configured according to this information:
--chainId: Specify the Chain ID ganache-cli will use for eth_chainId RPC and the CHAINID opcode. For legacy reasons, the default is currently 1337 for eth_chainId RPC and 1 for the CHAINID opcode. Setting this flag will align the chainId values. This will be fixed in the next major version of ganache-cli and ganache-core!
Possibly this will change in the future, but at the moment it's the setting that works.
- 111
- 4

