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

Can't use rpc http api when using docker image #14623

Closed
buxx opened this issue Jun 14, 2017 · 10 comments
Closed

Can't use rpc http api when using docker image #14623

buxx opened this issue Jun 14, 2017 · 10 comments

Comments

@buxx
Copy link

buxx commented Jun 14, 2017

Hello,

I'm trying to setup a ethereum (with docker) on personal dedicated server, then use it with personal computer installed Ethereum Wallet/Mist. But RPC api seems not available. Thank's.

System information

uname -a
Linux xyz 3.14.32-xxxx-grs-ipv6-64 #7 SMP Wed Jan 27 18:05:09 CET 2016 x86_64 GNU/Linux
docker run -it -p 8545:8545 -p 30303:30303 -v /data/ethereum:/root/.ethereum ethereum/client-go --rpc --rpcaddr "127.0.0.1"
[...]
INFO [06-14|19:53:39] Starting peer-to-peer node               instance=Geth/v1.6.6-unstable/linux-amd64/go1.7.3
[...]
INFO [06-14|19:50:38] HTTP endpoint opened: http://127.0.0.1:8545 
INFO [06-14|19:50:38] IPC endpoint opened: /root/.ethereum/geth.ipc 

Expected behaviour

RPC HTTP interface available on http://127.0.0.1:8545.

Actual behaviour

No RPC HTTP interface on http://127.0.0.1:8545:

curl http://127.0.0.1:8545
curl: (56) Recv failure: Connection reset by peer

Steps to reproduce the behaviour

Run docker run -it -p 8545:8545 -p 30303:30303 -v /data/ethereum:/root/.ethereum ethereum/client-go --rpc --rpcaddr "127.0.0.1" then run curl http://127.0.0.1:8545.

@lmars
Copy link
Contributor

lmars commented Jun 14, 2017

@buxx setting --rpcaddr to 127.0.0.1 means that geth is listening on the local interface inside the Docker container, which is distinctly different from the local interface on your machine.

What you need to do is run docker with -p 127.0.0.1:8545:8545 to map your local 8545 port to the docker container's public 8545 port, and then set --rpcaddr to 0.0.0.0 so that geth listens on the container's public interface.

So:

$ docker run -p 127.0.0.1:8545:8545 -p 30303:30303 -v /data/ethereum:/root/.ethereum ethereum/client-go --rpc --rpcaddr "0.0.0.0"

@buxx
Copy link
Author

buxx commented Jun 15, 2017

Hello,

I'm totally sorry you're entirely right !

Bux.

@EvilJordan
Copy link

I greatly appreciate this thread as I was having the same issue, but I cannot get it to work! Running geth on the machine itself, I can connect just fine. If it's running inside Docker, though, connections are refused (and, in fact, I don't even see the "HTTP endpoint opened" message in the logs.

Any idea what might be going on?

@lmars
Copy link
Contributor

lmars commented Jan 19, 2018

@EvilJordan are you running that exact command that I posted?

@EvilJordan
Copy link

EvilJordan commented Jan 19, 2018

@lmars I'm running this:
docker run -p 127.0.0.1:8545:8545 -p 30303:30303 -v /data/ethereum:/root/.ethereum ethereum/client-go:alpine --syncmode "light" --cache=512 --rpc --rpcaddr "0.0.0.0"

I've also tried with:
docker run -p 127.0.0.1:8545:8545 -p 30303:30303 -v /data/ethereum:/root/.ethereum ethereum/client-go --syncmode "light" --cache=512 --rpc --rpcaddr "0.0.0.0"
and
docker run -p 127.0.0.1:8545:8545 -p 30303:30303 -v /data/ethereum:/root/.ethereum ethereum/client-go --rpc --rpcaddr "0.0.0.0"

@lmars
Copy link
Contributor

lmars commented Jan 19, 2018

@EvilJordan ok, and then what? Are you getting an error somewhere?

@EvilJordan
Copy link

@lmars No, no errors at all. I think it has something to do with the container<->docker relationship and port bindings. I'm still digging away!

@milos-mkv
Copy link

It is not working!

@rickkk137
Copy link

--http --http.port=8545 --http.addr=0.0.0.0 --http.vhosts="*" --allow-insecure-unlock --http.api="db,eth,net,web3,personal"
add this options that worked for me

@holiman
Copy link
Contributor

holiman commented Sep 7, 2021

--allow-insecure-unlock --http.api="db,eth,net,web3,personal" PSA: this is highly dangerous, and can make remote attackers sign arbitrary transactions whenever you use unlock on an account.

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

6 participants