Skip to content
Latchkey

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.

elasticsearch
ConnectionError: There are no living connections
    at ClientOptions.onConnectionError

Common 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

  1. Block on _cluster/health?wait_for_status=yellow in a setup step.
  2. Only construct the client after the cluster is ready.
  3. Point the client at the correct host, port, and scheme.
Terminal
until curl -sf "http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=5s"; do
  sleep 2
done

Give 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.

JavaScript
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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →