I'm following this official Ethereum's tutorial to create a hello world.

In this tutorial we need to use alchemy, which doesn't supports ropsten anymore, the only test network avaliable in alchemy is goerli.

So, to continue the tutorial, I replaced all ropsten content with goerli.

But, when I try to deploy the smart contract, with:

npx hardhat --network goerli run scripts/deploy.js

I got the following error:

Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2)
    at Logger.makeError (/home/caio/Área de trabalho/hello-world-eth/node_modules/@ethersproject/logger/src.ts/index.ts:269:28)
    at Logger.throwError (/home/caio/Área de trabalho/hello-world-eth/node_modules/@ethersproject/logger/src.ts/index.ts:281:20)
    at EthersProviderWrapper.<anonymous> (/home/caio/Área de trabalho/hello-world-eth/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:483:23)
    at step (/home/caio/Área de trabalho/hello-world-eth/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:23)
    at Object.throw (/home/caio/Área de trabalho/hello-world-eth/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:29:53)
    at rejected (/home/caio/Área de trabalho/hello-world-eth/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:21:65)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  reason: 'could not detect network',
  code: 'NETWORK_ERROR',
  event: 'noNetwork'

My hardhat.config.js code:

* @type import('hardhat/config').HardhatUserConfig 


const { API_URL, PRIVATE_KEY } = process.env;

module.exports = {
  solidity: "0.8.17",
  defaultNetwork: "goerli",
  networks: {
    hardhat: {},
    goerli: {
      url: API_URL,
      accounts: [`0x${PRIVATE_KEY}`]

I just copied the example code from the tutorial and replaced ropsten with goerli.

Also, this file exact the same as seen in this Alchemy's tutorial, that is an "updated" version of the ethereum's tutorial, but using goerli.


I found the error, the alchemy's goerli url was wrong in the .env file, already fixed and working now!

1 Answer 1


According to the hardhat docs, the command is npx hardhat run scripts/deploy.js --network <network-name>, so it's npx hardhat run scripts/deploy.js --network goerli. Also, make sure you have the network, chainId, url, and accounts set up in the hardhat.config.js file.

See: https://hardhat.org/tutorial/deploying-to-a-live-network

  • I just copied the tutorial's example code inside the hardhat.config.js file and replaced the ropsten with goerli.
    – CaioBonani
    Commented Oct 20, 2022 at 20:17
  • Using the correct command still gives me the same error.
    – CaioBonani
    Commented Oct 20, 2022 at 20:25
  • did you include the goerli chainId? Commented Oct 20, 2022 at 20:31
  • Yes, I did. But I found the error, I forgot to replace the eth-ropsten with eth-goerl in the .env file. Running the command now works!
    – CaioBonani
    Commented Oct 20, 2022 at 20:43

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.