in-solana by Supanode

getHealth — Solana RPC Method

getHealth returns the current health status of the node. A healthy node is within a reasonable slot distance of the cluster. This method is designed for load balancers and monitoring systems to check if an RPC node is operational.

Parameters

This method takes no parameters.

Request

curl -X POST https://api.mainnet-beta.solana.com \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getHealth",
    "params": []
  }'

TypeScript (@solana/kit)

import { createSolanaRpc } from "@solana/kit";

const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");

try {
  const health = await rpc.getHealth().send();
  console.log(`Node health: ${health}`);
} catch (error) {
  console.error("Node is unhealthy");
}

Response (healthy)

{
  "jsonrpc": "2.0",
  "result": "ok",
  "id": 1
}

Response (unhealthy)

{
  "jsonrpc": "2.0",
  "error": {
    "code": -32005,
    "message": "Node is behind by 150 slots",
    "data": {
      "numSlotsBehind": 150
    }
  },
  "id": 1
}
ScenarioResponse
Healthy"result": "ok"
Unhealthy (behind)Error with numSlotsBehind in data
UnknownError with no additional data

Understanding health status

A node is considered healthy when it is within a configured number of slots of the highest known slot in the cluster. The exact threshold depends on the node’s --health-check-slot-distance configuration. By default, a node reports unhealthy when it falls more than 128 slots behind.

An unhealthy response is returned as a JSON-RPC error (not a successful result), which means it has an HTTP 200 status code but contains an error field. The numSlotsBehind value tells you how far behind the node is.

Common errors

  • Node behind — the node’s slot is lagging behind the cluster. The numSlotsBehind field indicates how many slots it trails.
  • Node unhealthy (unknown) — the node cannot determine its health status, possibly because it has not yet caught up to the cluster or has lost connectivity to other nodes.

Performance

getHealth is the lightest possible RPC call. It reads local node state and returns immediately. It is designed for high-frequency polling by load balancers and health-check systems. Safe to call every few seconds.

FAQ

How do I use getHealth for load balancing? Configure your load balancer to poll getHealth on each RPC node periodically (every 5-10 seconds). Route traffic only to nodes that return "ok". Remove nodes from the pool when they return errors.

What does “behind by N slots” mean? The node’s highest processed slot is N slots less than the highest slot known in the cluster. This can happen during node restarts, network issues, or when a node is catching up after being offline.

Is a 200 HTTP status guaranteed for healthy nodes? No — both healthy and unhealthy responses return HTTP 200. You must check the JSON body for either "result": "ok" or an "error" field. Some providers may return non-200 codes for truly unreachable nodes, but the standard behavior is always HTTP 200 with JSON-RPC formatted responses.

How quickly does a node recover? Recovery time depends on how far behind the node is. A node 100 slots behind typically catches up within a minute. A node thousands of slots behind (after a restart) may take several minutes as it replays the ledger.

Updated: