Elasticsearch client "NoNodeAvailable" / "No living connections" in CI
The Elasticsearch client marked every node in its connection pool as dead and gave up with NoNodeAvailable (Java client) or "No living connections" (Node.js client). In CI this almost always means the client started before the cluster was reachable and never got a healthy node to retry against.
What this error means
The client throws "NoNodeAvailable[None of the configured nodes are available]" or "ConnectionError: No living connections" even though the container is defined in the workflow.
ConnectionError: There are no living connections
at ClientOptions.onConnectionErrorCommon causes
The cluster was unreachable when the pool initialized
Every configured node failed its first request, so the client marked them all dead and had none to route to.
The client started before the service was ready
The test connected during startup, before the port and cluster were serviceable, so no node ever went healthy.
How to fix it
Wait for the cluster before creating the client
- Block on
_cluster/health?wait_for_status=yellowin a setup step. - Only construct the client after the cluster is ready.
- Point the client at the correct host, port, and scheme.
until curl -sf "http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=5s"; do
sleep 2
doneGive the client sane retry and sniffing settings
Disable node sniffing against a single-node CI cluster and allow a few retries so a brief startup delay does not empty the pool.
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200', maxRetries: 5, sniffOnStart: false })How to prevent it
- Wait for yellow before the client is constructed.
- Disable sniffing against a single-node CI service.
- Allow a few retries so a short startup delay is absorbed.