diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/configuration/WebserverConfiguration.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/configuration/WebserverConfiguration.java index 36f3ae9b7..78591c44a 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/configuration/WebserverConfiguration.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/configuration/WebserverConfiguration.java @@ -78,6 +78,10 @@ public class WebserverConfiguration { return config.get(WebserverSettings.PORT); } + public String getInternalIP() { + return config.get(WebserverSettings.INTERNAL_IP); + } + public boolean isWebserverDisabled() { return config.isTrue(WebserverSettings.DISABLED); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/http/JettyWebserver.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/http/JettyWebserver.java index c8673be83..37e0ea669 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/http/JettyWebserver.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/http/JettyWebserver.java @@ -121,6 +121,8 @@ public class JettyWebserver implements WebServer { }); connector.setPort(port); + String internalIP = webserverConfiguration.getInternalIP(); + connector.setHost(internalIP); webserver.addConnector(connector); if (usingHttps) { @@ -129,10 +131,19 @@ public class JettyWebserver implements WebServer { webserver.setHandler(jettyRequestHandler); } + String startFailure = "Failed to start Jetty webserver: "; try { webserver.start(); + } catch (IOException e) { + if (e.getMessage().contains("Failed to bind")) { + boolean defaultInternalIp = "0.0.0.0".equals(internalIP); + String causeHelp = defaultInternalIp ? ", is the port (" + port + ") in use?" : ", is the Internal_IP (" + internalIP + ") invalid? (Use 0.0.0.0 for automatic)"; + throw new EnableException(startFailure + e.getMessage() + causeHelp, e); + } else { + throw new EnableException(startFailure + e.toString(), e); + } } catch (Exception e) { - throw new EnableException("Failed to start Jetty webserver: " + e.toString(), e); + throw new EnableException(startFailure + e.toString(), e); } webserverLogMessages.infoWebserverEnabled(getPort());