How do I get web3 currentProvider HTTP URL? I'm using web3 1.0.0-beta.34. I tried many functions and already looked at the docs - but still couldn't find the right way to get the URL of the current HTTP RPC node.

The pseudocode that I'm looking for:

if (is_using_http_rpc_fn) {
  return currentProvider.url;

What functions to call for is_using_http_rpc_fn and currentProvider.url in above pseudocode?

  • 1
    I looked for an answer myself, but I don't think that it is possible. When you connect to e.g. ropsten using MetaMask, MetaMask will connect to a URL like https://ropsten.infura.io/TOKEN, where TOKEN is unique for the MetaMask application. If you could read out the URL, you'd get the private token, which is why I think that there are security reasons for why this it not possible. What you can do is call web3.version.getNetwork(result => console.log(result)) to see the Network version
    – Peter
    Commented Aug 13, 2018 at 16:42

2 Answers 2


Based on @robertdavid's answer I found out that it's now


Confirmed this works for web3 1.0.0-beta.37


I think you can simply use:


Confirmed this works for web3 1.0.0-beta36.

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.