I'm trying to build my first dapp using test-rpc and web3js. I deployed a smart contract (with remix ide) to the testrpc (on linux ubuntu), when executing the following line:

web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); web3.eth.defaultAccount = web3.eth.accounts[0];

I'm getting the following error:

web3.min.js:1 Access to XMLHttpRequest at 'http://localhost:8545/' from origin '' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute. t.send @ web3.min.js:1 n.send @ web3.min.js:1 t @ web3.min.js:1 u.sendTransaction @ web3.min.js:1 u.execute @ web3.min.js:1 (anonymous) @ (index):105 dispatch @ jquery-3.2.1.slim.min.js:3 q.handle @ jquery-3.2.1.slim.min.js:3

I looked over this error before and one solution that didn't help is to use local http server (chrome browser extension).

I've looked for many similar problems and none of them helped. I'll really appreciate any kind of help.


  • the browser is enforcing the CORS policy, I looked and test-rpc / ganache dosent seem to have an option like '--rpc-cors-origins=*'. If i was in your situation for working with test-rpc I would use a http / web3 client in a test. – Nigel Savage Feb 17 at 19:37

Your Answer

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

Browse other questions tagged or ask your own question.