I'm new to Ethereum and i just setup my first Node. Basically i needed a way to query the Ethereum blockchain to retrieve data, so i decided to setup a light node on a VPS using Geth.

Everything seems to work, the node is up, but now what i don't understand is what i need to do in order to query the node and get Ethereum data. For example, when i use Web3JS or Web3py, what url do i need to set on my provider, in order to access my own node? Thanks in advance!


By default, your node run a json rpc api.

You can connect either through http or ws. By default, it only listens on localhost :

- HTTP : http://localhost:8545
- WebSockets : ws://localhost:8546

You can specify the interface you wish to listen on.

For http, start geth with --http.addr and connect with

const web3 = new Web3(new Web3.providers.HttpProvider(`http://{IP}:8545/`));

For ws, start geth with --ws --ws.addr and connect with

const web3 = new Web3(new Web3.providers.WebsocketProvider(`ws://{IP}:8546/`));
  • Thank you a lot for your answer! Is it possible that i need to do something else? Because whatever i try, when i try to access it from outside the vps, i always get a False when i print w3.isConnected(), while if i do it from inside the vps it returns True
    – Jack022
    Feb 17 '21 at 10:03
  • Check if firewall is accepting external connections on port 8545 and 8546
    – Xavier59
    Feb 17 '21 at 11:59
  • So if i do telnet 8545 from the Vps it connects, if i do telnet <MY-IP> 8545 it doesn't connect, so i think that's the problem; is there any way i can make it accept the connection?
    – Jack022
    Feb 17 '21 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.