redis/node-redis · error · Error

Master Node Not Enumerated

Error message

Master Node Not Enumerated

What it means

In `getMasterNode()`, the loop sets `connected = true` as soon as one sentinel responds, but if every responding sentinel yields a master record that `parseNode` rejects (undefined), none is returned and the method throws 'Master Node Not Enumerated'. This distinguishes 'sentinels reachable but do not know this master' from 'sentinels unreachable'.

Solutions

  1. Verify `options.name` exactly matches the monitored master name (`SENTINEL masters` on a sentinel).
  2. Confirm the sentinels you point at actually monitor that master.
  3. Re-check the master record flags reported by the sentinel.

Example fix

// before
new RedisSentinel({ name: 'MyMaster', rootNodes }, id); // wrong case
// after
new RedisSentinel({ name: 'mymaster', rootNodes }, id); // matches SENTINEL monitor name
Defensive patterns

Strategy: validation

Validate before calling

async function masterNameKnownBySentinel(rootNodes: { host: string; port: number }[], name: string, opts?: { password?: string }): Promise<boolean> {
  for (const n of rootNodes) {
    const c = new RedisClient({ modules: RedisSentinelModule, socket: { host: n.host, port: n.port }, password: opts?.password });
    try {
      await c.connect();
      const masters = await c.sentinel.sentinelMasters();
      c.destroy();
      if (masters.some(m => m.name === name)) return true;
    } catch { /* next */ }
  }
  return false;
}

Type guard

function isValidMasterName(name: unknown): name is string {
  return typeof name === 'string' && name.length > 0;
}

Try / catch

try { return await sentinel.getMasterNode(); }
catch (e) {
  if (String(e).includes('Master Node Not Enumerated')) {
    throw new Error(`No sentinel monitors a master named '${opts.name}'`);
  }
  throw e;
}

Prevention

When it happens

Trigger: Passing a `name` that no monitored master matches; sentinel reachable but not configured to monitor the requested master name; master record flags make parseNode return undefined for all sentinels.

Common situations: Typo in the master `name` (e.g. 'mymaster' vs 'MyMaster'); pointing at a sentinel deployment that monitors a different master; sentinel that lost its master config.

Related errors


AI-assisted analysis of redis/node-redis@90fd0652bc (2026-08-11). Data as JSON: /api/errors/95df6e12348c0a3c. Report an issue: GitHub.

Appendix: source

Thrown at packages/client/lib/sentinel/index.ts:1758

      connected = true;

      try {
        const masterData = await client.sentinel.sentinelMaster(this.options.name);

        const master = parseNode(masterData);
        if (master === undefined) {
          continue;
        }

        return master;
      } finally {
        client.destroy();
      }
    }

    if (connected) {
      throw new Error("Master Node Not Enumerated");
    }

    throw new Error("couldn't connect to any sentinels");
  }

  async getMasterClient() {
    const master = await this.getMasterNode();
    const socket = getMappedNode(master.host, master.port, this.options.nodeAddressMap);
    return RedisClient.create({
      ...this.options.nodeClientOptions,
      socket: {
        ...this.options.nodeClientOptions?.socket,
        host: socket.host,
        port: socket.port
      }
    });
  }

View on GitHub (pinned to 90fd0652bc)