Unable to deploy upgradable smart-contract tutorial on Polygon testnet using hardhat

Hello All, I'm following this tutorial for learning about How to deploy upgradable SC. Everything went well till upgrades.deployProxy script. But when I'm trying to deploy upgradeProxy then I'm getting below error.

Please note that I'm using polygon-testnet instead of localhost.

Error

Upgrading Box...
HardhatError: HH110: Invalid JSON-RPC response received: {"error":{"details":"Internal RPC Error. Try again after some time..","code":-32005},"jsonrpc":"2.0","id":6}
    at Object.parseJsonResponse (/home/alpha/GoWorkspace/src/github.com/metadata/solidity/openzeppelin_upgrdabale_sc/node_modules/hardhat/src/internal/util/jsonrpc.ts:47:11)
    at HttpProvider._fetchJsonRpcResponse (/home/alpha/GoWorkspace/src/github.com/metadata/solidity/openzeppelin_upgrdabale_sc/node_modules/hardhat/src/internal/core/providers/http.ts:173:14)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at HttpProvider.request (/home/alpha/GoWorkspace/src/github.com/metadata/solidity/openzeppelin_upgrdabale_sc/node_modules/hardhat/src/internal/core/providers/http.ts:55:29)
    at Object.getStorageAt (/home/alpha/GoWorkspace/src/github.com/metadata/solidity/openzeppelin_upgrdabale_sc/node_modules/@openzeppelin/upgrades-core/src/provider.ts:47:19)
    at getEip1967Storage (/home/alpha/GoWorkspace/src/github.com/metadata/solidity/openzeppelin_upgrdabale_sc/node_modules/@openzeppelin/upgrades-core/src/eip-1967.ts:32:17)
    at Object.getAdminAddress (/home/alpha/GoWorkspace/src/github.com/metadata/solidity/openzeppelin_upgrdabale_sc/node_modules/@openzeppelin/upgrades-core/src/eip-1967.ts:9:19)
    at getUpgrader (/home/alpha/GoWorkspace/src/github.com/metadata/solidity/openzeppelin_upgrdabale_sc/node_modules/@openzeppelin/hardhat-upgrades/src/upgrade-proxy.ts:50:26)
    at Proxy.upgradeProxy (/home/alpha/GoWorkspace/src/github.com/metadata/solidity/openzeppelin_upgrdabale_sc/node_modules/@openzeppelin/hardhat-upgrades/src/upgrade-proxy.ts:35:23)
    at main (/home/alpha/GoWorkspace/src/github.com/metadata/solidity/openzeppelin_upgrdabale_sc/scripts/upgrade_box.js:13:3)

Hardhat-config.js

require("@nomiclabs/hardhat-waffle");
require('@nomiclabs/hardhat-ethers');
require('@openzeppelin/hardhat-upgrades');

// for using .env file which contains private info. 
require('dotenv').config();
const POLYGON_TEST_PRIVATE_KEY = process.env.POLYGON_TEST_PRIVATE_KEY;
const POLYGON_TEST_API_KEY = process.env.POLYGON_TEST_API_KEY;

task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
  const accounts = await hre.ethers.getSigners();

  for (const account of accounts) {
    console.log(account.address);
  }
});

/**
 * @type import('hardhat/config').HardhatUserConfig
 */
module.exports = {
 
  defaultNetwork: "polygon_test",
  networks: {
    hardhat: {
    },
  
    polygon_test: {
      url: `https://rpc-mumbai.maticvigil.com/v1/${POLYGON_TEST_API_KEY}`,
      chainId: 80001,
      // If "auto" is used, the gas limit will be automatically estimated. Default value: "auto"
      gas: "auto",
      // Its value should be "auto" or a number. This parameter behaves like gas. Default value: "auto"
      gasPrice: "auto",
      accounts: [`0x${POLYGON_TEST_PRIVATE_KEY}`],
      // You can use this field to set extra HTTP Headers to be used when making JSON-RPC requests. It accepts a JavaScript
      // object which maps header names to their values. Default value: undefined
      //httpHeaders: '',
      timeout: 20000
    }
  },
  solidity: {
    version: "0.8.4",
    settings: {
      optimizer: {
        enabled: true,
        runs: 200
      }
    }
  },
  paths: {
    sources: "./contracts",
    tests: "./test",
    cache: "./cache",
    artifacts: "./artifacts"
  },
  mocha: {
    timeout: 20000
  }
};

Contracts
Box.sol

// contracts/Box.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

contract Box {
    uint256 private _value;

    // Emitted when the stored value changes
    event ValueChanged(uint256 value);

    // Stores a new value in the contract
    function store(uint256 value) public {
        _value = value;
        emit ValueChanged(value);
    }

    // Reads the last stored value
    function retrieve() public view returns (uint256) {
        return _value;
    }
}

deploy-box.js

const hre = require("hardhat");

async function main() {
  // We get the contract to deploy
  const Box = await hre.ethers.getContractFactory("Box");
  const box = await Box.deploy();

  await box.deployed();

  console.log('Box deployed to:', box.address);
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

deploy-proxy.js

// scripts/deploy_upgradeable_box.js
const { ethers, upgrades } = require('hardhat');

async function main () {
  const Box = await ethers.getContractFactory('Box');
  console.log('Deploying Box...');
  const box = await upgrades.deployProxy(Box, [42], { initializer: 'store' });
  await box.deployed();
  console.log('Box deployed to:', box.address);
}

main()
.then(() => process.exit(0))
.catch(error => {
  console.error(error);
  process.exit(1);
});

BoxV2.sol

// contracts/BoxV2.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

contract BoxV2 {
    // ... code from Box.sol
    uint256 private _value;

    event ValueChanged(uint256 value);

    // The onlyOwner modifier restricts who can call the store function
    function store(uint256 value) public {
        _value = value;
        emit ValueChanged(value);
    }

    function retrieve() public view returns (uint256) {
        return _value;
    }
    // Increments the stored value by 1
    function increment() public {
        _value = _value + 1;
        emit ValueChanged(_value);
    }
}

deploy-upgradeProxy-box.js

// scripts/upgrade_box.js
const { ethers, upgrades } = require('hardhat');

async function main () {
  
  // the address of our proxy contract from when we deployed our Box contract  
  const proxyAddress = '0x4e4660AAc4aC123d881B6DD6dF7Fb884c82264ED';

  const BoxV2 = await ethers.getContractFactory('BoxV2');
  console.log('Upgrading Box...');

  await upgrades.upgradeProxy(proxyAddress, BoxV2);
  console.log('Box upgraded');
}

main().then(() => process.exit(0)).catch(error => {
    console.error(error);
    process.exit(1);
});

Have you confirmed that the RPC endpoint is working? Try some other operation like await ethers.provider.getBlockNumber().

Yes, RPC is working fine. Below is the snippet.

> await ethers.provider.getBlockNumber()
17575626

@frangio found same issue and after changing the rpc endpoint It worked.