Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to allow remote connections to ethereum node ? #2982

Closed
aronayne opened this issue Sep 7, 2016 · 8 comments
Closed

How to allow remote connections to ethereum node ? #2982

aronayne opened this issue Sep 7, 2016 · 8 comments

Comments

@aronayne
Copy link

aronayne commented Sep 7, 2016

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 ?

@joeb000
Copy link

joeb000 commented Sep 7, 2016

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

@aronayne
Copy link
Author

aronayne commented Sep 7, 2016

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.

@joeb000
Copy link

joeb000 commented Sep 7, 2016

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...

@bas-vk
Copy link
Member

bas-vk commented Sep 9, 2016

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.

@bas-vk bas-vk closed this as completed Sep 9, 2016
@aronayne
Copy link
Author

aronayne commented Sep 9, 2016

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

@thosuperman
Copy link

You can try with

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

@eddieoz
Copy link

eddieoz commented Sep 21, 2018

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.

@thosuperman
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants