Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
How to get Javalin's Jetty http server to bind/listen on a specific address/port?

Using Javalin.create().port(portNumber) sets the listen port, but it's unclear how to set the listen/bind address.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Found out that you can create the Jetty Server instance yourself and configure it. In Kotlin:

    val port = Integer.parseInt(System.getProperty("PORT", "8080"))
    val jettyServer = JettyServerUtil.defaultServer()
    jettyServer.apply {
        connectors = arrayOf(ServerConnector(jettyServer).apply {
            this.host = System.getProperty("HOST", "0.0.0.0")
            this.port = port
        })
    }
    val app = Javalin.create()
            .port(port)
            .server { jettyServer }
            .start()
over 4 years ago · Santiago Trujillo Report

0

Here's how to do the same in Java:

int port = Integer.parseInt(System.getProperty("PORT", "8080"))
org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server();
ServerConnector connector = new ServerConnector(server);
connector.setHost(System.getProperty("HOST", "0.0.0.0"));
connector.setPort(port);
server.setConnectors(new ServerConnector[] { connector });

Javalin app = Javalin.create(config -> {
    config.server(() -> server);
}).start(port);

Reference: https://github.com/tipsy/javalin/issues/138

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!