I am having an issue with smart contract deployment using hardhat. I don't see where is the error coming from. I have defined the .env file with values and also correctly called those values using process.env here is my hardhat.config file :


/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  defaultNetwork: "goerli",
  paths: {
    artifacts: "./artifacts",


  networks: {
    goerli: {
      chainId: 5,
    goerli: {
      url: process.env.API_URL ,
      accounts: [process.env.PRIVATE_KEY] ,
  solidity: "0.8.0",
}; ```
  • this is the error : Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2) Nov 20, 2022 at 2:32
  • Why are you defining Goerli twice? Nov 20, 2022 at 2:38
  • hi @OlivierD i was advised to add goerli chain ID, i just removed it, but still i get the error Nov 20, 2022 at 2:45
  • You can add the chainId, but put it all inside one. No reason for you to have 2 “goerli”. Also, what’s in your process.env? Obviously, don’t share private keys! Nov 20, 2022 at 2:50
  • so what do you think courses the error? Nov 20, 2022 at 3:01

1 Answer 1


I believe what is happening is that the specific node you are trying to use to access the blockchain could be down or not available.... But before you assume that, try running whatever task you are doing using your local node and if it works then your online node must be down In my case, I got the error

Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2)

and I solved it by changing the goerli_rpc_url in my environment variable from an alchemy supplied one to one from infuria from




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.