Invalid JSON RPC response when using Alchemy Goerli testnet

623 Views Asked by At

I have a script that is always connected to Alchemy RPC Endpoint, and it was running well all the time. But when I try to run npx hardhat deploy --network goerli today, I encounter the error message as shown. Does anyone encounter this problem before?

Nothing to compile
failed to get chainId, falling back on net_version...
Error HH110: Invalid JSON-RPC response received: <!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Just a moment...</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="robots" content="noindex,nofollow">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link href="/cdn-cgi/styles/challenges.css" rel="stylesheet">
</head>

Below is my hardhat.config.js file.

require("@nomicfoundation/hardhat-toolbox")
require("@nomicfoundation/hardhat-chai-matchers")
require("@nomiclabs/hardhat-etherscan")
require("hardhat-deploy")
require("solidity-coverage")
require("hardhat-gas-reporter")
require("hardhat-contract-sizer")
require("dotenv").config()

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

const GOERLI_RPC_URL = process.env.GOERLI_RPC_URL
const PRIVATE_KEY = process.env.PRIVATE_KEY
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY
const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY

module.exports = {
    defaultNetwork: "hardhat",
    networks: {
        localhost: {
            // url: "http://127.0.0.1:8545/",
            //accounts: those 10 fake accounts generated by local
            chainId: 31337,
        },
        hardhat: {
            chainId: 31337,
            // url: "http://127.0.0.1:8545/",
            // blockConfirmations: 1
        },
        goerli: {
            blockConfirmations: 1,
            url: GOERLI_RPC_URL,
            accounts: [PRIVATE_KEY],
            chainId: 5,
        },
    },
    solidity: {
        compilers: [
            {
                version: "0.8.9",
            },
            {
                version: "0.8.0",
            },
        ],
    },
    namedAccounts: {
        deployer: {
            default: 0,
        },
        player: {
            default: 1,
        },
    },
2

There are 2 best solutions below

0
Hari Pandey On

try Resetting your Metamask, and re-configure your ChainID other than 31337

0
Nint On

I was facing the same problem, I just pasted the actual URL instead of importing through from .env file. This may do the work