SECURITY WARNING: Never run commands you don't understand. Always review code before execution. Use at your own risk.
Web3 New Added 26 September 2026

Web3: could not detect network (event="noNetwork", code=NETWORK_ERROR)

ethers asks the endpoint for its chain id before it will do anything else, and that call failed, so the provider never finished starting. A wrong URL is only one cause: a missing key in the path, a rate limited key, a browser CORS rejection and an http endpoint on an https page all look identical from here.

Quick fix

Read the commands before running them. Anything that restarts a service, deletes data or changes permissions should be tried on a non-production system first.

Quick fix
# Prove the endpoint answers before blaming the library
curl -s -X POST $RPC -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"eth_chainId","params":[]}'

// Skip the detection round trip when the chain is known
const provider = new ethers.JsonRpcProvider(RPC_URL, 1, { staticNetwork: true });

// A 401 or 429 from the provider also reads as noNetwork, so log the detail
provider.on('error', (e) => console.error(e.info ?? e));

// In the browser the wallet already knows its network
const browserProvider = new ethers.BrowserProvider(window.ethereum);

// Env vars that never reached the bundle are the usual local cause
console.log(process.env.RPC_URL ?? 'undefined');   // Vite needs a VITE_ prefix

# A local node that is not up yet: wait for it rather than constructing early
cast block-number --rpc-url http://127.0.0.1:8545

How to diagnose Web3 errors

Web3 errors are unusually terse because the EVM reports failure without explanation by default. execution reverted means a require or revert triggered. The reason string is present in the return data but most libraries discard it. Nonce errors reflect the strict sequential ordering of transactions per account, so a stuck transaction blocks every one behind it.

If the quick fix above does not resolve it, work through these steps. They apply to this whole class of error, not just to this one message, which is usually what saves the time.

  1. Simulate before sending: eth_call against the same block returns the revert reason string that a submitted transaction hides.
  2. Use a transaction tracer (Tenderly, Foundry's cast run, or a node's debug_traceTransaction) to see the exact opcode and contract where execution reverted.
  3. For nonce errors, query the account's pending nonce (eth_getTransactionCount with the pending tag) rather than tracking it locally.
  4. To replace a stuck transaction, resend with the same nonce and a materially higher gas price: most nodes require at least a 10% increase.
  5. Check the chain ID matches the network you intend. Signing for the wrong chain produces confusing rejection messages.

Tools worth reaching for

  • cast (Foundry)
  • eth_call simulation
  • Tenderly / block explorer tracer
  • debug_traceTransaction

Authoritative references

Primary documentation for this error, worth reading before applying any fix in production.

docs.ethers.org ethereum.org

Related Web3 errors

See all 17 Web3 errors →

Browse other categories

Something missing or wrong?

This entry is maintained by hand. If the fix is out of date, incomplete, or you have a better one, email a correction and it will be reviewed.