this is what I am using

I have tried everything but just can't get the web3.currentProvider to work. I have metamask installed and working and somehow want to connect the website on the test network. Has there been some recent update which is not reflected in the documentation?

2 Answers 2


The problem here is likely that you are trying to run your page locally, which is explicitly restricted in MetaMask:

🌐 Http(s) - Web Server Required

Due to browser security restrictions, we can't communicate with dapps running on file://. Please use a local server for development.

You will need to publish your code to a local server to test MetaMask functionality.

In the situation where you do not need the MetaMask user context, you can use the HttpProvider fallback using infura.io:


window.web3 = new Web3(new Web3.providers.HttpProvider("https://mainnet.infura.io/<APIKEY>"));

This should allow you to do basic read operations on the Ethereum blockchain without needing to deploy to a local test server.


I don't know how my Metamask(Firefox Extension) got updated, but it sure did. Before the update, I was able to connect properly. It had a security setting which I had to disable to connect.

After update, I had to add sites which are to be allowed to use Metamask. Take a look at this.

enter image description here

I just needed to add localhost as site and it then the website on localhost was able to connect to Metamask

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.