I'm totally new to Ethereum, and want to create some deposit address monitoring system using web socket. Which gets newly generated blocks and scan it for transactions made into it. You can find code here: https://github.com/AlanL1/Ethereum-FrontEnd

But geth is not connected with application. I have already installed geth

enter image description here

Am i missing something?

  • Is metamask installed, if yes, you can select metamask network "localhost 8545" from metamask dropdown. metamask itself injects web3 instance, you should create new instance like 'web3js' with window.web3js = new Web3(web3.currentProvider);
    – kherwa
    Commented May 14, 2018 at 10:42
  • If I select local host from dropdown, it just stuck with Connecting to Unknown Private Network
    – Hina
    Commented May 14, 2018 at 11:04
  • start geth with "geth --testnet --rpc --rpccorsdomain="*"
    – kherwa
    Commented May 14, 2018 at 11:07
  • Fatal: Error starting protocol stack: listen udp :30303: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted
    – Hina
    Commented May 14, 2018 at 11:08
  • you must have already running geth
    – kherwa
    Commented May 14, 2018 at 11:09

1 Answer 1


you can use this sample code:

    if(type of web3 !== 'undefined'){
         // Use injected web3 by Metamask/Mist
         window.web3js = new Web3(web3.currentProvider);
     } else {
         // Fallback to local node
         // you can use Infura Node Urls also
         // '' will be replaced by 
         // 'https://ropsten.infura.io/<API KEy>'
         window.web3js = new Web3(new Web3.providers.HttpProvider(''));

here you can see i have added web3js instance, instead of replacing web3 instance injected by Metamask or Mist.


To consume JSON-RPC API's over WebSockets, use web3.js beta version 1.0.0-beta https://github.com/ethereum/web3.js/tree/1.0

First expose RPC API's over Web Socket Interface

geth --testnet --ws --wsorigins="*"

then instantiate web3 in your page as

web3 = new Web3("ws://");   

Written a detailed blog on setting up local geth node & communicating with it. http://blog.kherwa.com/2018/05/10/building-a-dapp-series-part1-set-up-and-communicate-with-an-ethereum-node/

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.