apache/dubbo · error · IllegalStateException

Duplicated port used by protocol configs, port: <port>, conf

Error message

Duplicated port used by protocol configs, port: <port>, configs: <Arrays.asList(prevProtocol, protocol)>

What it means

Thrown by ConfigManager during the final port-conflict check: two ProtocolConfig instances declare the same non-null, non-(-1) port. Dubbo binds each protocol to its port, so a collision would prevent startup; the check lists both conflicting configs. Ports of null or -1 are auto-assigned and skipped.

Source

Thrown at dubbo-common/src/main/java/org/apache/dubbo/config/context/ConfigManager.java:349

                MonitorConfig.class,
                MetricsConfig.class,
                TracingConfig.class,
                SslConfig.class);

        for (Class<? extends AbstractConfig> configType : multipleConfigTypes) {
            checkDefaultAndValidateConfigs(configType);
        }

        // check port conflicts
        Map<Integer, ProtocolConfig> protocolPortMap = new LinkedHashMap<>();
        for (ProtocolConfig protocol : getProtocols()) {
            Integer port = protocol.getPort();
            if (port == null || port == -1) {
                continue;
            }
            ProtocolConfig prevProtocol = protocolPortMap.get(port);
            if (prevProtocol != null) {
                throw new IllegalStateException("Duplicated port used by protocol configs, port: " + port
                        + ", configs: " + Arrays.asList(prevProtocol, protocol));
            }
            protocolPortMap.put(port, protocol);
        }

        // Log the current configurations.
        logger.info("The current configurations or effective configurations are as follows:");
        for (Class<? extends AbstractConfig> configType : multipleConfigTypes) {
            getConfigs(configType).forEach((config) -> logger.info(config.toString()));
        }
    }

    public ConfigMode getConfigMode() {
        return configMode;
    }
}

View on GitHub (pinned to 3a3043227f)

Solutions

  1. Assign distinct ports to each protocol.
  2. Omit the port (or set -1) to let Dubbo auto-assign for protocols that support it.
  3. Remove a duplicate protocol config that is no longer needed.

Example fix

<!-- before -->
<dubbo:protocol name="dubbo" port="20880"/>
<dubbo:protocol name="rest" port="20880"/>
<!-- after -->
<dubbo:protocol name="dubbo" port="20880"/>
<dubbo:protocol name="rest" port="8080"/>
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check port collisions among protocol configs
Map<Integer, ProtocolConfig> seen = new HashMap<>();
for (ProtocolConfig p : configManager.getProtocols()) {
    Integer port = p.getPort();
    if (port == null || port == -1) continue;
    if (seen.containsKey(port)) {
        throw new IllegalStateException("Port collision on " + port + " between " + seen.get(port) + " and " + p);
    }
    seen.put(port, p);
}
configManager.getDefaultConfiguration(); // triggers validation

Type guard

static boolean noProtocolPortCollisions(List<ProtocolConfig> protocols) {
    java.util.Set<Integer> ports = new java.util.HashSet<>();
    for (ProtocolConfig p : protocols) {
        Integer port = p.getPort();
        if (port == null || port == -1) continue;
        if (!ports.add(port)) return false;
    }
    return true;
}

Try / catch

try {
    configManager.getDefaultConfiguration();
} catch (IllegalStateException e) {
    if (e.getMessage().startsWith("Duplicated port used by protocol configs")) {
        // parse port, reassign one of the conflicting protocols
    } else throw e;
}

Prevention

When it happens

Trigger: Two <dubbo:protocol> beans with the same port (e.g. two REST protocols on 8080, or dubbo and rest both pinned to 20880). Programmatic ProtocolConfig with colliding setPort().

Common situations: Adding a second protocol and reusing an existing port. Spring Boot properties dubbo.protocols.<id>.port colliding. Copy-pasting a protocol config without changing the port.

Related errors


AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14). Data as JSON: /api/errors/45382c9549c1fcd6. Report an issue: GitHub.