'HardHat and Rinkeby ProviderError: Must be authenticated Error

When I run

npx hardhat console --network rinkeby

accounts = await ethers.provider.listAccounts();

I get

Uncaught ProviderError: Must be authenticated!

with below rinkeby network config in hardhat.config.js

rinkeby: {
  url: "ALCHEMY_URL",
  accounts:["YOUR_PRIVATE_KEY"],
}


Solution 1:[1]

Solution: update config file with below lines:

rinkeby: {
        url: "ALCHEMY_URL",
        accounts: ["YOUR_PRIVATE_KEY"],
        gas: 2100000,
        gasPrice: 8000000000,
        saveDeployments: true,
    }

This works like a charm. Hope this helped in saving some of your time.

Solution 2:[2]

Finally, your hardhat.config.js should look like this

require('@nomiclabs/hardhat-waffle');

module.exports = {
  solidity: '0.8.0',
  networks: {
    ropsten: {
       url: `${ARCHEM_APP_URL}`,
       accounts: [`${ACCOUNT_KEY}`],
       gas: 2100000,
       gasPrice: 8000000000,
       saveDeployments: true,
    }
  }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shirish Singh
Solution 2 Patrick Niyogitare