diff --git a/java/server/src/org/openqa/grid/web/Hub.java b/java/server/src/org/openqa/grid/web/Hub.java index 045cd701a1555..e16995be74fdb 100644 --- a/java/server/src/org/openqa/grid/web/Hub.java +++ b/java/server/src/org/openqa/grid/web/Hub.java @@ -54,6 +54,7 @@ public class Hub { private final int port; private final String host; + private final boolean isHostRestricted; private final Registry registry; private final Map> extraServlet = Maps.newHashMap(); @@ -77,9 +78,11 @@ public Hub(GridHubConfiguration config) { if (config.getHost() != null) { host = config.getHost(); + isHostRestricted = true; } else { NetworkUtils utils = new NetworkUtils(); host = utils.getIp4NonLoopbackAddressOfThisMachine().getHostAddress(); + isHostRestricted = false; } this.port = config.getPort(); @@ -101,6 +104,9 @@ private void initServer() { server = new Server(); SocketConnector socketListener = new SocketConnector(); socketListener.setMaxIdleTime(60000); + if (isHostRestricted) { + socketListener.setHost(host); + } socketListener.setPort(port); server.addConnector(socketListener);