Skip to Content
DocumentationRpcCheck Health

Check Health

The checkHealth function checks the health status of the Solana cluster node you’re connected to.

Usage

const isHealthy = await connection.checkHealth();

Parameters

None.

Returns

Returns a Promise<boolean>:

  • true if the node is healthy
  • false if the node is unhealthy or unreachable

Example

// Check if the node is healthy const isHealthy = await connection.checkHealth(); if (isHealthy) { console.log("Node is healthy and ready to process transactions"); } else { console.log("Node is unhealthy or unreachable"); } // Use in error handling try { const isHealthy = await connection.checkHealth(); if (!isHealthy) { throw new Error("RPC node is not healthy"); } // Proceed with transactions } catch (error) { console.error("Health check failed:", error); }

Use Cases

  • Monitoring RPC node health before critical operations
  • Implementing fallback logic when a node is unhealthy
  • Health checks in production monitoring systems
  • Validating connection before bulk operations

Notes

  • A healthy node returns “ok” from the underlying RPC call
  • If the RPC call fails or returns any other status, the function returns false
  • This is a quick way to verify your RPC connection is working
  • Consider checking health before submitting important transactions
Last updated on