Specifying `"localhost"` in `server.listen` does not work.
See original GitHub issueThe following does not work but likely should mimic common behavior between other js libs.
let server = Ganache.server();
server.listen(8888, 'localhost');
There’s no direct error and everything seems to function. However, after deploying a contract and trying to make calls to it(at least with the ethers lib from my own testing) results in an Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.6.8)
.
However, the following works as expected.
let server = Ganache.server();
server.listen(8888, '127.0.0.1');
For consistency/commonly thought of behavior 'localhost'
should provide the same behavior as directly writing out the localhost address.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
express app server . listen all interfaces instead of localhost only
If you don't specify host while calling app.listen, server will run on all interfaces available i.e on 0.0.0.0. You can bind the IP...
Read more >Localhost Refused to Connect Error: 5 Confirmed Ways to Fix It
Localhost refused to connect error can be caused by an incorrectly configured port, insufficient permissions, or an inoperative web server.
Read more >"Server is not listening on port 3000" but application is running.
Got this issue with express@4.16.1. I figured out that it was because the usage of app.listen() in app.js and "node /bin/www" in package.json ......
Read more >Can't connect to node HTTP server running on localhost
I'm trying to write an integration test which for now simply launches a Node server, then queries it to check if it's running...
Read more >How to listen on port 80 with Node.js ? - GeeksforGeeks
Specify Port Number and hostname and set the server to listen to it. server.listen(port,hostname,callback);. What happens when we listen to port ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Assuming that the issue is caused by nodejs/node#40702, you may find that the problem abates on node 16.x.x. You may also find that if you check the output of
lsof -i -P | grep LISTEN | grep 8545
, thenode
process that hosts ganache will be listening on IPv6 (usually the 5th column in the output).We just encountered and fixed what’s likely the same issue with the Truffle dashboard. I wrote up a fairly in-depth explanation of the problem on the related issue at trufflesuite/truffle#5690, and the fix can be seen at trufflesuite/truffle#5699.
I think this is related, on my machine (which, for context, produced the error @benjamincburns is referencing) if I run ganache on localhost and my
truffle-config
is set to127.0.0.1
I get the error:If I change my
truffle-config
to uselocalhost
as well, then it will work. This leads me to believe it is the IP resolution issue.