how to make jetty server accessible from LAN?

Viewed 34661

I am trying to access a web app (deployed in jetty8 on my machine (A)) from another machine (B) on the LAN using 192.168.0.6:8080 (A's IP) but its not working. While I can access apps hosted on AppServ on machine B from A normally using 192.168.0.5 (B's IP).

I can access the app normally on localhost:8080 on machine A.

I can assure that there is no network problem, but jetty is not accessible through the network for some reason. Is there any specific configuration to make accessible through the LAN?

My app is Maven project and I run it from eclipse and settings are in both web.xml and pom.xml.

3 Answers

2020-07-20

As an addition to @JoakimErdfelt answer, on Jetty 9.4.12.v20180830 (and above), you can configure the host programatically as:

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;

    Server server = new Server();       

    ServerConnector httpConnector = new ServerConnector(server);
        httpConnector.setHost("0.0.0.0"); // <--------- !
        httpConnector.setPort(12345);
        httpConnector.setIdleTimeout(5000);
        server.addConnector(httpConnector);
Related