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
- Assign distinct ports to each protocol.
- Omit the port (or set -1) to let Dubbo auto-assign for protocols that support it.
- 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
- Assign distinct ports per protocol in config.
- Use -1 or omit port for auto-assignment where supported.
- Add a startup assertion that protocol ports are unique.
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
- url missing protocol: "${fullURLStr}"
- More than 1 default extension name on extension {}: {}
- url missing protocol: "<url>"
- <config>.<key> == null
- Append parameters failed: <message>
AI-assisted analysis of apache/dubbo@3a3043227f (2026-08-14).
Data as JSON: /api/errors/45382c9549c1fcd6.
Report an issue: GitHub.