Facing an issue with the url to make Rpc while deploying the contract

190 Views Asked by At

VS code terminal:

JsonRpcProvider {}
Deploying the contract.........
JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started) 
Error: connect ECONNREFUSED 127.0.0.1:7545
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1595:16) {
  errno: -4078,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 7545
}


const provider = new ethers.JsonRpcProvider("http://127.0.0.1:7545"); //there is an issue with the url passed but its the same url as Rpc server from ganache.

I have passed the Rpc server url from ganache to the JsonRpcProvider , but am facing an issue with the url. Please fix this

1

There are 1 best solutions below

0
On

Here are the few things, which you can try.

1:Check if ganache is running and is using the correct port 7545. and no other processes using the same port 7545.

2:You can also try updating ganache and use a different port.

3:Try stopping an restarting ganache. Restarting the Ganache server can resolve connection issues.

4:You can try the following way for creating the json rpc provider instance.

const { ethers } = require("ethers");
const provider = new ethers.providers.JsonRpcProvider("http://127.0.0.1:7545");