Go-ethereum: How to allow remote connections to ethereum node ?

Created on 7 Sep 2016  路  8Comments  路  Source: ethereum/go-ethereum

System information

Geth version: Version: 1.4.11-stable-fed692f6
OS & VersionLinux

Expected behaviour

Can see the listening port is 30303 from geth stdout :
I0907 09:39:10.482998 p2p/server.go:556] Listening on [::]:30303

web3.setProvider(new web3.providers.HttpProvider('http://MY_IP:30303'));
var coinbase = web3.eth.coinbase;

Actual behaviour

var coinbase = web3.eth.coinbase; returns error :
Error: Invalid JSON RPC response: undefined

Steps to reproduce the behaviour

Access coinbase using : var coinbase = web3.eth.coinbase;

Backtrace

[backtrace]

This could be occurring due to ethereum not allowing remote connections by default ? How to configure ethereum to allow remote connections on LAN ?

Most helpful comment

geth --rpc --testnet --networkid 3 --rpcport "8545" --rpcaddr "0.0.0.0" --rpccorsdomain "*"

Just adding some security concerns: this is the most unsecure way to configure your node and making it available on internet. It opens the rpc to the world, being possible to connect to it from any place.

There're many bots already watching nodes with rpc exposed and if sometime you unlock a wallet on that node, you're at risk of having all of your balance stolen thru rpc connection.

All 8 comments

Geth uses port 30303 for connections to peers. You are attempting to attach to a geth RPC endpoint. You'll first need to make sure you are running geth with --rpc to expose the JSON RPC interface. Then you'll want to attach to port 8545 (default RPC port).

By default, geth will only allow RPC calls originating from the same device as geth is running. You'll need to use --rpcaddr and --rpccorsdomain flags to allow external RPC connections (although this is not advisable from a security standpoint).

I highly recommend checking this page out for more info on the RPC API: https://github.com/ethereum/wiki/wiki/JSON-RPC#go

Additionally, you might be interested in this thread: http://ethereum.stackexchange.com/questions/3163/how-can-i-expose-geths-rpc-server-to-external-connections

thanks @joeb000 I can now start and connect with
sudo ./geth --rpc --rpcaddr --rpcport 8546

Invoking coinbase now throws new error :

var coinbase = web3.eth.coinbase;
Error: etherbase address must be explicitly specified

But this appears to be a separate issue.

yes, you'll need to create an account on your device running the geth node (geth account new) or alternatively set your etherbase using the geth flag.

I'm also wondering why you are running geth with sudo, you should be able to run it as a normal user on your machine. You're probably fine, but in general its probably not good practice to give blockchain applications root access...

Please visit the go-ethereum gitter channel on https://gitter.im/ethereum/go-ethereum. There are people who can help you with these kind of questions. I'm closing this since it's not an issue with the project but a support question.

thanks @bas-vk , I should have closed as issue was resolved.

You can try with

geth --rpc --testnet --networkid 3 --rpcport "8545" --rpcaddr "0.0.0.0" --rpccorsdomain "*"

geth --rpc --testnet --networkid 3 --rpcport "8545" --rpcaddr "0.0.0.0" --rpccorsdomain "*"

Just adding some security concerns: this is the most unsecure way to configure your node and making it available on internet. It opens the rpc to the world, being possible to connect to it from any place.

There're many bots already watching nodes with rpc exposed and if sometime you unlock a wallet on that node, you're at risk of having all of your balance stolen thru rpc connection.

@eddieoz: Thank you for your comment. Actually this setting use for testing and develop purpose only.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

phpsamsb picture phpsamsb  路  3Comments

keitaj picture keitaj  路  3Comments

bgrieder picture bgrieder  路  3Comments

AdrianScott picture AdrianScott  路  3Comments

aomiba picture aomiba  路  3Comments