diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/NettyWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/NettyWebServer.java index 7938b9eb7c..e2daf9bde3 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/NettyWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/NettyWebServer.java @@ -101,7 +101,7 @@ public class NettyWebServer implements WebServer { } catch (Exception ex) { PortInUseException.ifCausedBy(ex, ChannelBindException.class, (bindException) -> { - if (!isPermissionDenied(bindException.getCause())) { + if (bindException.localPort() > 0 && !isPermissionDenied(bindException.getCause())) { throw new PortInUseException(bindException.localPort(), ex); } });