Search code examples
playframeworktypesafe-activator

How to change the http port for play framework 2.5.9


How to change the default port from 9000 to 9001 in Play 2.5.9?

Tried following steps

  1. Changed http.port = 9001 in application.conf
  2. Tried the steps mentioned in this post [a link] How to change the http port for play framework 2.4.1?

But this works activator run -Dhttp.port=9001 -Dhttp.address=127.0.0.1

Can we change it from application.conf instead of specifying port from command line?


Solution

  • In a way, no you can not add HTTP server setting in application.conf in reload mode (activator run).

    In run mode by the time the play server starts, your application.conf is not resolved yet, but if you use state it works fine.

    If you want to avoid providing port everytime you run the command, you could add it in build.sbt as following.

    PlayKeys.devSettings := Seq("play.server.http.port" -> "9001")

    It is explained here