Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Failed to load http://localhost:8545/ #1826

Closed
MuhammadAhmad-BlockchainDeveloper opened this issue Aug 1, 2018 · 9 comments
Closed

Failed to load http://localhost:8545/ #1826

MuhammadAhmad-BlockchainDeveloper opened this issue Aug 1, 2018 · 9 comments

Comments

@MuhammadAhmad-BlockchainDeveloper

while interfacing my node.js project with smart contract and deploy it, i am getting this error.
i have also attached screenshots of error

[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.

Failed to load http://localhost:8545/: 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'. Origin 'http://localhost:3000' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

Uncaught Error: CONNECTION ERROR: Couldn't connect to node http://localhost:8545.
at Object.InvalidConnection (web3.min.js:1)
at t.send (web3.min.js:1)
at n.send (web3.min.js:1)
at l.accounts (web3.min.js:1)
at sol:45

xx

@pierreneter
Copy link
Contributor

you must add param: --rpccorsdomain "http://localhost:3000" when you run your local node.

@nivida nivida closed this as completed Aug 10, 2018
@loydbanks
Copy link

I was able to fix this error, the version of web3 must be downgraded, navigate to the folder you want to save in, run npm init then the following code
Use this command to install: npm install [email protected] --save within the same folder and this worked fine for me

@SUBHRA7
Copy link

SUBHRA7 commented Sep 26, 2018

@loydbanks I was also facing the same issue and I tried with your solution but get this 2 below error now. Please help me out to resolve.
Failed to load resource: net::ERR_CONNECTION_REFUSED
i.send @ web3.min.js:1
web3.min.js:1 Uncaught Error: CONNECTION ERROR: Couldn't connect to node http://localhost:8545.
at Object.InvalidConnection (web3.min.js:1)
at i.send (web3.min.js:1)
at s.send (web3.min.js:1)
at _.accounts (web3.min.js:1)
at index.html:41

@SUBHRA7
Copy link

SUBHRA7 commented Sep 26, 2018

@loydbanks solved. forgot to run testrpc.

@therightstuff
Copy link

therightstuff commented Sep 26, 2018

@SUBHRA7 could you please provide the entire command? i've actually opened a PR that sets required credentials to false when no credentials are supplied for use in testing, with that it's a matter of running
geth --dev --rpc --rpccorsdomain="*" --rpcaddr="localhost"
and then using the default web3 connection

EDIT: @loydbanks the PR's change allows access without downgrading

@loydbanks
Copy link

loydbanks commented Sep 26, 2018 via email

@therightstuff
Copy link

therightstuff commented Sep 26, 2018

@loydbanks the emails are github notifications, so i'm not sure i understand what you're referring to. if you look at the PR i linked to previously you'll be able to make the latest version of web3 work with localhost (and be able to build it properly); you can see the changes i've made here until the PR is approved (assuming it ever will be)

@nivida
Copy link
Contributor

nivida commented Sep 28, 2018

@therightstuff no wories I‘ll have a look on your PR next week

@sitsiya
Copy link

sitsiya commented Jun 27, 2019

write in php
header("Access-Control-Allow-Origin: http://localhost:8545");

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants