Trying to connect Ganache GUI running on port 7545
to web3.js
. Getting the below error whenever trying to call any of the functions of web3 -
> web3.eth.getBalance("0x907A41F173099E5F5573F0ab43B6Dd9594e3687a").then(console.log);
Promise { <pending> }
> Uncaught Error: Invalid JSON RPC response: ""
at Object.InvalidResponse (/mnt/c/.../web3_development/node_modules/web3-core-helpers/lib/errors.js:43:16)
at XMLHttpRequest.request.onreadystatechange (/mnt/c/.../web3_development/node_modules/web3-providers-http/lib/index.js:95:32)
at XMLHttpRequestEventTarget.dispatchEvent (/mnt/c/.../web3_development/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
at XMLHttpRequest._setReadyState (/mnt/c/Users/.../web3_development/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
at XMLHttpRequest._onHttpRequestError (/mnt/c/.../web3_development/node_modules/xhr2-cookies/dist/xml-http-request.js:349:14)
Running node
on WSL-2.
Any help as to what might be causing the issue or ways to resolve it would be really helpful.
Thanks a lot!!
let web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:7545'));
localhost
. Ganache has got the option to change host to WSL. It works now. Thanks a lot for all your help