How to tell if connection good from JavaScript?


I am using Node/JavaScript to access elasticsearch. I am using the 1.4 API.

If a connection fails (using new elasticsearch.Client(...)), the 'new'
succeeds. You don't know the connection failed till you try to use it.
Okay, I can live with that. What I can't live with is the backtrace I get
when I try to use it rather than just an error return.

I get no error when I connect (to the wrong port). But I get the following
when I try to use it:

Elasticsearch ERROR: 2015-01-23T17:14:40Z Error: Request error, retrying --
connect ECONNREFUSED at Log.error
at checkRespForFailure
at HttpConnector.
at ClientRequest.bound
at ClientRequest.emit (events.js:95:17) at Socket.socketErrorListener
(http.js:1552:9) at Socket.emit (events.js:95:17) at net.js:441:14 at
process._tickCallback (node.js:442:13) Elasticsearch WARNING:
2015-01-23T17:14:40Z Unable to revive connection: http://localhost:920/
Elasticsearch WARNING: 2015-01-23T17:14:40Z No living connections error: No
Living connections

I tried using and with the same results.

Thanks for the help!

Blake McBride

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
For more options, visit