redis/redis ยท error

Invalid address format: %s

Error message

Invalid address format: %s

What it means

Printed by clusterManagerCommandCreate (src/redis-cli.c:7327) when one of the `host:port` arguments passed to `redis-cli --cluster create` cannot be split into ip and port by parseClusterNodeAddress (the address contains no `:`). The create command refuses to start because it cannot even build the node list.

Source

Thrown at src/redis-cli.c:7327

    } else if (config.stdin_tag_arg) {
        sdsfree(config.cluster_manager_command.stdin_arg);
    }
    freeClusterManager();

    exit(success ? 0 : 1);
}

/* Cluster Manager Commands */

static int clusterManagerCommandCreate(int argc, char **argv) {
    int i, j, success = 1;
    cluster_manager.nodes = listCreate();
    for (i = 0; i < argc; i++) {
        char *addr = argv[i];
        char *ip = NULL;
        int port = 0;
        if (!parseClusterNodeAddress(addr, &ip, &port, NULL)) {
            fprintf(stderr, "Invalid address format: %s\n", addr);
            return 0;
        }

        clusterManagerNode *node = clusterManagerNewNode(ip, port, 0);
        if (!clusterManagerNodeConnect(node)) {
            freeClusterManagerNode(node);
            return 0;
        }
        char *err = NULL;
        if (!clusterManagerNodeIsCluster(node, &err)) {
            clusterManagerPrintNotClusterNodeError(node, err);
            if (err) zfree(err);
            freeClusterManagerNode(node);
            return 0;
        }
        err = NULL;
        if (!clusterManagerNodeLoadInfo(node, 0, &err)) {
            if (err) {

View on GitHub (pinned to 3acc0c49cf)

Solutions

  1. Rewrite every node argument in `ip:port` form, e.g. `127.0.0.1:7000 127.0.0.1:7001`.
  2. If using hostnames, still append the port: `node1.example.com:7000`.
  3. For IPv6 literals use the bracketed form `[::1]:7000` so the port-colon is unambiguous.
  4. Double-check shell expansion: `echo` your full command first to confirm no empty `$VAR`.

Example fix

// before
redis-cli --cluster create 127.0.0.1 127.0.0.1 127.0.0.1 --cluster-replicas 1
// after
redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 --cluster-replicas 1
Defensive patterns

Strategy: validation

Validate before calling

// Validate an address string in 'host:port' or 'host port' form BEFORE passing it in.
function validateAddressFormat(addr) {
  if (typeof addr !== 'string' || addr.trim().length === 0) {
    throw new Error('Invalid address format: empty');
  }
  const m = addr.trim().match(/^(\[[^\]]+\]|[^:\[\]\s]+)(?::|\s+)(\d{1,5})$/);
  if (!m) throw new Error(`Invalid address format: ${addr}`);
  const port = Number(m[2]);
  if (!Number.isInteger(port) || port < 1 || port > 65535) {
    throw new Error(`Invalid port in address: ${addr}`);
  }
  return { host: m[1].replace(/^\[|\]$/g, ''), port };
}
const ep = validateAddressFormat(inputAddr);

Type guard

// Narrow a string to a confirmed 'host:port' address.
function isHostPortString(v) {
  if (typeof v !== 'string') return false;
  const m = v.trim().match(/^(\[[^\]]+\]|[^:\[\]\s]+)(?::|\s+)(\d{1,5})$/);
  if (!m) return false;
  const p = Number(m[2]);
  return Number.isInteger(p) && p > 0 && p < 65536;
}

Try / catch

try {
  result = parseAddress(userInput);
} catch (e) {
  if (/Invalid address format/i.test(String(e.message))) {
    throw new Error(`Rejecting malformed cluster address from caller: '${userInput}'`);
  }
  throw e;
}

Prevention

When it happens

Trigger: Run `redis-cli --cluster create n1 n2 n3 ...` where any argument is a bare hostname/IP with no `:port`, or contains only a port. parseClusterNodeAddress returns 0 when strrchr(addr, ':') is NULL.

Common situations: Copy-pasting `redis-cli --cluster create host1 host2 host3` instead of `host1:7000 host2:7000 host3:7000`; shell variable that expanded empty so the port segment is missing; accidentally passing the cluster bus port as a separate token.

Related errors


AI-assisted analysis of redis/redis@3acc0c49cf (2026-08-01). Data as JSON: /data/errors/ea42b57de44b8204.json. Report an issue: GitHub.