My code transfers coins from a bunch of wallets to the main one. Previously, with ethers 5.7x it used to work well. However, it doesn't any longer.

I used to have this:

const provider = ethers.getDefaultProvider("goerli");

Now I've obtained an API key of etherscan (because of a warning "you should obtain an API key"...), upgraded ethers to v6.3.0 and changed the code to this:

const provider = ethers.getDefaultProvider("goerli", {
  etherscan: process.env.ETHERSCAN_API_KEY

And it's gotten broken. There's 1 or 2 errors:

TypeError: unsupported network (argument="network", value="goerli", code=INVALID_ARGUMENT, version=6.3.0)

code: 'INVALID_ARGUMENT', argument: 'network', value: 'goerli'

And, as a result of it:

server response 403 Forbidden (request={  }, response={  }, error=null, code=SERVER_ERROR, version=6.3.0)

What's the matter? How's goerli "unsupported"? Eventually I'll be using it with the mainnet, obvisouly, but at the moment I'm testing it with goerli

2 Answers 2


I also ran into the same issue. I'm using ethers ^6.3.0.

It seems that the documentation doesn't provide a sufficient explanation on how to use the getDefaultProvider method in v6.

I did some digging into the source code and found out that the getDefaultProvider function in the ethers.js source code doesn't accept "goerli" as a valid network parameter.

Instead, you need to specify either the RPC URL or the WebSocket URL.

Take a look at the code snippet below (source):

export function getDefaultProvider(network: string | Networkish | WebSocketLike, options?: any): AbstractProvider {
  if (options == null) { options = { }; }

  if (typeof(network) === "string" && network.match(/^https?:/)) {
    return new JsonRpcProvider(network);

  if (typeof(network) === "string" && network.match(/^wss?:/) || isWebSocketLike(network)) {
    return new WebSocketProvider(network);

To resolve this, instead of a network name (eg. "goerli"), pass a public RPC URL. You can find a list of RPC server addresses here.

I used one from Ankr, but any valid RPC URL should work. You don't need to provide an API key.

const defaultProvider = ethers.getDefaultProvider(

I hope this helps resolves your issue :)


ethers.js made some pretty extensive changes in V6, and it looks like the default providers were replaced with community providers.

You can find the updated options in the ethers V6 docs.

Keep in mind these are public endpoints that are heavily limited; you should definitely consider getting your own endpoint. Many services let you start for free, and Chainstack, for example, offers Ethereum mainnet and Goerli endpoints.

You should also consider what you need to do on the testnet. If you are developing a DApp consider using the Sepolia testnet, as it's the testnet dedicated to developing smart contracts and DApps. Goerli should be reserved for validators testing.

Chainstack supports Sepolia as well, and you can get 1 node endpoint for free on the developer plan.

Once you have your own endpoint, it's easier to create a provider instance on ethers.js V6 with the following code:

const ethers = require('ethers');
const NODE_URL = "NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);

You can find more examples on the Chainstack API docs!

  • You haven't answered my question. Instead, you've advertized your service and given unwanted advice
    – Kyell
    Commented Apr 14, 2023 at 17:59
  • https://docs.ethers.org/v6/api/providers/ --> according to it, my code should still work.
    – Kyell
    Commented Apr 14, 2023 at 18:00
  • I'm sorry you see it as unwanted advice. This is what the Ethereum Foundation recommends for development, for example: ethereum.org/en/developers/docs/networks/…. Also, using a more reliable endpoint might help solve many issues out of the box. As I mentioned, there are many free options; Alchemy and Quicknode are other providers, for example. The V6 docs don't mention the getDefaultProvider that you are using, but there are community providers instead, so it looks like it changed, but maybe I misunderstood. Commented Apr 14, 2023 at 19:20

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.