Quick note

Error: connect ECONNREFUSED when integration testing a Node.js app

In an express.js app that I was integration testing using Mocha the tests suddenly started acting weird with complaint such as:

"before all" hook: Error: connect ECONNREFUSED

Turned out the root cause was a test method that should have been asynchronous wasn't, it was declared as function() instead of function(done). Pretty obvious in hindsight but with an error message like that it took a while to locate.

Joel Abrahamsson

Joel Abrahamsson

I'm a passionate web developer and systems architect living in Stockholm, Sweden. I work as CTO for a large media site and enjoy developing with all technologies, especially .NET, Node.js, and ElasticSearch. Read more

More about Programming