19

Why do some ethereum related websites (for example regis.nu, there are many others) tell me they cannot find a node running at http://localhost:8545 and what can I do about that?

Regis.nu allowed me to create a "light-wallet" and then I had to put some ether in there, but I didn't really want to do that. I wanted to use my own wallet. I tried starting 'geth' but now I'm going into deep water and I can't swim.

So question: How can I start a node at http://localhost:8545?

2 Answers 2

24

http://localhost:8545 is the RPC port of your locally running Ethereum node software.

When running geth, the Go implementation of the Ethereum node software, the command line parameters to create and configure this RPC service follows:

user@Kumquat:~$ geth --help | grep rpc
  --rpc                         Enable the HTTP-RPC server
  --rpcaddr "127.0.0.1"         HTTP-RPC server listening interface
  --rpcport "8545"              HTTP-RPC server listening port
  --rpcapi "db,eth,net,web3"    API's offered over the HTTP-RPC interface
  --rpccorsdomain               Domains from which to accept cross origin requests (browser enforced)

The defaults for --rpcaddr, --rpcport and --rpcapi will allow the regis.nu webpage to connect to your local geth node. You will however need to configure the --rpccorsdomain to allow your web browser to get access to your local Ethereum node.

To start a node on your local machine providing the regis.nu webpage with access to your node, try:

geth --rpc --rpcaddr "127.0.0.1" --rpcport "8545" \
  --rpc --rpccorsdomain "http://regis.nu" console

Note: Setting --rpccorsdomain to "http://regis.nu" will work with the regis.nu webpage. If you are having trouble connecting, start testing with "*" to check whether the webpage can connect to your node, then find the correct setting to minimise your security risk - see Cross-origin resource sharing for more information. And note that using "*" could be risky.

Looking into the JavaScript code in regis.nu/main.js linked from regis.nu, you will see:

 module.exports={nodeAddress:["http://localhost:8545","http://104.41.138.167:8545"], ...}

The page will firstly try connecting to your RPC port locally, then try the RPC port available at IP address 104.41.138.167 .

I loaded http://regis.nu in my web browser, then clicked on the Start button, but the website could not connect to the RPC port of my locally running geth. I had to temporarily allow http://localhost in my NoScript addon within my browser before the regis.nu web page was allowed to connect to my local geth node and list my accounts.

Useful reference:

4
  • I read somewhere that --rpccorsdomain "*" was a bit overly open. May I put the domain name (in this case regis.nu) in there? Thanks for the very informative answer by the way. Commented Apr 24, 2016 at 12:49
  • 1
    I've just tested the web page, and setting --rpccorsdomain to regis.nu does not work, but http://regis.nu works. Commented Apr 24, 2016 at 13:15
  • 1
    Thanks. Another place I saw this happen was etherid.org where they say explicitly (now that I see it): Please note that using --rpccorsdomain "*" is dangerous. Commented Apr 24, 2016 at 13:24
  • You should use instead --rpccorsdomain "subdom.domain.com" like for example with multiple options: --rpccorsdomain "*.myetherwallet.com,*.ethereum.org"
    – Andy B.
    Commented Apr 11, 2018 at 18:44
0

The default Localhost 8545 network setting hard codes ChainID to 5777. However Ganache has abandoned setting ChainID to always be 5777. We cannot rely on this anymore (source: I asked). This produces really hard to debug error messages such as "This contract is not deployed on this network".

I found this out by changing the MetaMask provider to:

new ethers.providers.JsonRpcProvider("http://127.0.0.1:8545") And it worked. So I decided to compare the two providers and see what was different. It turns out the ChainID was always (incorrectly) set to 5777.

To Reproduce

Start a Ganache instance with ganache-cli Change MetaMask to the default "Localhost 8545" setting Inspect the window.ethereum object Notice that the ChainID is 5777 regardless of the real ChainID (displayed in the terminal when you run ganache-cli) Current Workaround

Simply create a new network profile (with the "Custom RPC" option in the dropdown) with http://127.0.0.1:8545 and leave all defaults blank and the ChainID will be correct.

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.