question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FR: facilitate debugging of "could not detect network (event="noNetwork", code=NETWORK_ERROR..."

See original GitHub issue

Errors of the form Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/x.y.z) seem to crop up quite a bit, e.g.:

https://github.com/ethers-io/ethers.js/issues?q=is%3Aissue+event%3D"noNetwork"++code%3DNETWORK_ERROR

There appears to be no indication in the error of what went wrong, or in the documentation about how to debug this. One cause appears to be non-functional RPC endpoints, but this is certainly not the only one. For example, I am seeing this from hre.ethers.provider provided by hardhat-ethers with an RPC endpoint URL which works perfectly fine via new ethers.providers.JsonRpcProvider(url).

So I would suggest any/all of the following, in order to facilitate root cause analysis:

  • If possible, add more detail to the error message.
  • If not, provide some kind of tracing of network activity (e.g. export ETHERS_TRACE=network or similar).
  • Add some suggested trouble-shooting procedures to the docs.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ricmoocommented, Oct 3, 2022

The will help if the problem is the node is erroneously returning invalid responses. But for most other cases you won’t see much, unfortunately. 😦

1reaction
ricmoocommented, Oct 3, 2022

This is usually a link error, which means there is not really any meaningful way to get more info. If it is more than a link error, the provider.on("debug", console.log) can probably help.

Otherwise, link errors can occur because the node isn’t up and running yet, there is a firewall in the way (I.E mobile platforms like iOS and android block all http traffic), the geth instance hasn’t been configured to allow a connection over the default interface, etc.

There is not generally much that can be done at an application level to debug a bad network link as much of that is at the OS level, server configuration or network topology. 😒

Read more comments on GitHub >

github_iconTop Results From Across the Web

could not detect network (event="noNetwork", code - You.com
Here is my code being used for testing. It works in a small node program but will not work in React Native.
Read more >
Error: could not detect network (event="noNetwork", code ...
This happens if you run the code in WSL but Ganache is opened in Windows. Follow along the URL given in another answer...
Read more >
Error: Wallet has error: Error: could not detect network (event ...
Error: Wallet has error: Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.0.17).
Read more >
Error: could not detect network - Moralis Forum
I am trying to connect to the speedy bsc mainnet node but i suddenly get the following error: Error: could not detect network...
Read more >
Kony API Reference Guide | Manualzz
27.5 Registering for Network Status Change Notifications ... The API does not check for the availability of the media at the specified location....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found