Rather than have a local node on my PC, I'd like to be able to attach the geth cli console to INFURA and then issue requests within geth's java console, e.g. web3.eth.getBalance(<address>)

I signed up for INFURA and received an email with some endpoints to use, but I am unclear what specific commands I should use so that my geth console attaches to one of those endpoints.



2 Answers 2


I'm afraid you can't connect to a remote host because geth attach works via ipc.

Try this instead:

> npm install web3
> node 
> Web3 = require("web3");
> web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/<your access key>:8545"));
> web3.eth.blockNumber


Since version 1.4 geth attach supports rpc also however it doesn't work for me:

> geth attach https://mainnet.infura.io/<my access key>:8545
Fatal: Failed to start the JavaScript console: api modules: EOF
  • 1
    @mesqueeb check my answer below
    – 0xsegfault
    Commented Aug 8, 2018 at 7:54
  • 1
    web3.eth.blockNumber does not work, but you can do it asynchronously: web3.eth.getBlockNumber().then(res => console.log(res)) Commented Oct 1, 2018 at 22:58

The main infura nodes do not support geth attach. Infura maintains legacy nodes that they use for testing that it works for .

geth attach https://gmainnet.infura.io(geth)
geth attach https://pmainnet.infura.io (parity)

  • I get this error Fatal: Failed to start the JavaScript console: api modules: invalid character 'h' in literal true (expecting 'r')
    – JBrouwer
    Commented Sep 6, 2018 at 12:30
  • 1
    I get this error: Fatal: Failed to start the JavaScript console: api modules: Post https://gmainnet.infura.io: context deadline exceeded Commented Oct 1, 2018 at 22:53

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.