apache/shenyu · error · IllegalArgumentException

Port out of range (1-65535) in Redis node URL: " + url

Error message

Port out of range (1-65535) in Redis node URL: " + url

What it means

parseRedisNode validates that the parsed port is within the valid TCP range 1-65535 before creating a RedisNode. Ports outside that range (0, negative, or >65535) are invalid and produce this IllegalArgumentException. Note the port parse itself already rejects non-numeric values with a separate error.

Solutions

  1. Correct the port to a valid value in 1-65535 (Redis default is 6379)
  2. Check the actual port your Redis server listens on (redis-cli ping / CONFIG GET port)
  3. Validate port range in configuration before passing node URLs
  4. Search config files for suspicious ports like 0 or values above 65535

Example fix

// before
shenyu.redis.nodes=127.0.0.1:99999
// after
shenyu.redis.nodes=127.0.0.1:6379
Defensive patterns

Strategy: validation

Validate before calling

boolean validPort(String url) {
    int i = url == null ? -1 : url.trim().lastIndexOf(':');
    if (i < 0 || i == url.trim().length() - 1) return false;
    try {
        int p = Integer.parseInt(url.trim().substring(i + 1));
        return p >= 1 && p <= 65535;
    } catch (NumberFormatException e) { return false; }
}

Try / catch

try {
    RedisNode node = factory.parseRedisNode(url);
} catch (IllegalArgumentException e) {
    log.error("redis node port invalid: {}", url);
}

Prevention

When it happens

Trigger: A node URL like '127.0.0.1:0', '127.0.0.1:99999', or '127.0.0.1:-1' passed to redisNode/createRedisNode.

Common situations: Typo in the port number, copy-pasted port from another service, misremembering the Redis default (6379), config template with an out-of-range placeholder value.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12). Data as JSON: /api/errors/701e7c9b6dfbe45b. Report an issue: GitHub.

Appendix: source

Thrown at shenyu-infra/shenyu-infra-redis/src/main/java/org/apache/shenyu/infra/redis/RedisConnectionFactory.java:195

                if (portStr.isEmpty()) {
                    throw new IllegalArgumentException("Port cannot be empty in Redis node URL: " + url);
                }
                try {
                    port = Integer.parseInt(portStr);
                } catch (NumberFormatException e) {
                    throw new IllegalArgumentException("Invalid port in Redis node URL: " + url, e);
                }
                host = trimmedUrl.substring(0, lastColonIndex);
            } else if (lastColonIndex == 0 || lastColonIndex == trimmedUrl.length() - 1) {
                throw new IllegalArgumentException("Invalid format in Redis node URL: " + url);
            }
        }
        
        if (host.trim().isEmpty()) {
            throw new IllegalArgumentException("Host is empty in Redis node URL: " + url);
        }
        if (port < 1 || port > 65535) {
            throw new IllegalArgumentException("Port out of range (1-65535) in Redis node URL: " + url);
        }
        
        return new RedisNode(host.trim(), port);
    }
}

View on GitHub (pinned to 567142e072)