0

Happy New Year to everyone!

So I have an EC2 machine (with IP address 44.212.96.143) where I started a private block chain. I ran geth there using the command below:

geth --networkid 14333 
--datadir ./data --bootnodes enode://<enodeid>@44.212.232.178:0?discport=30303 --port 30305 
--ipcdisable --syncmode 'full' --http --allow-insecure-unlock --http.corsdomain "*" 
--http.port 8546 --authrpc.port 8547 --unlock '<account_id>' --password password.txt --mine console

Please that in above command 44.212.232.178 is the IP of my blockchain bootnode.

Now I am trying to connect my MetaMask to this private network. In MetaMask I entered the following details:

Network name: MyNetwork
New RPC URL: http://44.212.96.143:8547
Chain ID: 14333

However it tells me Could not fetch chain ID. Is your RPC URL correct?

Things I have tried:

I ensured that the security group policy of AWS allows all ports incoming and outgoing.

I replaced 8547 with all other possible port numbers I had in the geth command - 8546, 30303, 30305 but nothing worked.

I tried the solutions mentioned in this post and also in this post

Also, I did not see the "Custom RPC" option in MetaMask, so I am using the option "Networks > Add a network > Add a network manually"

I am unsure of what else to try. If anyone can give me some guidance or tips I would appreciate it so very much!

1 Answer 1

0
  1. Quick and Easy way (Due to security issue, it's highly not recommended solution): This will open your RPC to the public (which I guess what you wanted to do): I think you should add the two flags to allow remote RPC from any IP and any query: --http.vhosts * --http.addr 0.0.0.0. In your command --http.port 8546 is the port you want to config with MetaMask, you don't have to guess or try other ports.
  • Step 1: run the command again with two added flags as above:
geth --networkid 14333 
 --datadir ./data --bootnodes enode://<enodeid>@44.212.232.178:0?discport=30303 --port 30305 
 --ipcdisable --syncmode 'full' --http --allow-insecure-unlock --http.corsdomain "*"  --http.vhosts "*" --http.addr "0.0.0.0"
 --http.port 8546 --authrpc.port 8547 --unlock '<account_id>' --password password.txt --mine console
  1. If you can ssh to the instance, the more secure (and recommended) way is not using the flag above but to use ssh port forwarding to forward all your RPC traffic to the remote host. So for this solution, you keep the command you used in your question unchanged (port 8546) and use ssh port forwarding:
    • Assuming you have username that can ssh to the remote host at 44.212.96.143
    • Remote host: Run Geth like you ran before: geth --networkid 14333 ... --http.port 8546 ...
    • Your laptop/local machine: run ssh -N -L 8546:localhost:8546 [email protected]
    • Now you can use http://localhost:8546 for your metamask in the local machine personally.

You can also take a look at similar question: How can I expose Geth's RPC server to external connections?

2
  • Oh. My. God!! You are a LIFE SAVER! I wish I could give you a 100 thumbs up! That worked!!
    – Blav Orian
    Jan 3, 2023 at 17:45
  • @BlavOrian you are welcome :)
    – minhhn2910
    Jan 4, 2023 at 5:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.