Using Javalin.create().port(portNumber) sets the listen port, but it's unclear how to set the listen/bind address.
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With