3

I come from a play 1.2.7 application and currently getting started with play framework 2.4.1 and scala. For a start I use the activator web ui to manage applications and there I cannot get the application to use a different http port.

I changed the http.port setting in conf/application.conf, but still play 2.4.1 tries to bind to port 9000, which is already in use. The setting I tried is:

http.port=7000

Any suggestion on how to change the port for a play framework 2.4.1 application that is run via the activator web ui?

Note that as suggested in the linked question I can use

./activator "run 7000"

in the application itself to have it bind to port 7000. Still my question is how can I get the same behaviour via the activator web ui?

TeTeT
  • 2,044
  • 20
  • 30
  • 1
    possible duplicate of [How do I change the default port (9000) that Play uses when I execute the "run" command?](http://stackoverflow.com/questions/8205067/how-do-i-change-the-default-port-9000-that-play-uses-when-i-execute-the-run) – Mon Calamari Jul 01 '15 at 09:34
  • https://www.playframework.com/documentation/2.4.x/ProductionConfiguration – Roman Jul 01 '15 at 09:35
  • I followed the documentation and added http.port to application.conf, it just doesn't seem to be used. I don't use the play run method right now, but activator's web ui. – TeTeT Jul 01 '15 at 09:38

5 Answers5

10

Through the application.conf in production:

play.server.http.port = 80

When you run the application with SBT:

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

Using run command:

$ run 80

For more details please refer the below links:

documentation-Config File

documentation-Server configuration options

Yazan
  • 6,074
  • 1
  • 19
  • 33
Sriram
  • 167
  • 2
  • 11
1

Add the following to build.sbt of your project where <port> should be replaced with your desired port number.

build.sbt

fork in run := true
javaOptions in run += "-Dhttp.port=<port>"

Expected console output in Activator UI on run

Setting up Play fork run ... (use Ctrl+D to cancel)

--- (Running the application, auto-reloading is enabled) ---

p.a.l.c.ActorSystemProvider - Starting application default Akka system: application
p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:<port>

(Server started, use Ctrl+D to stop and go back to the console...)
Alexander B
  • 1,023
  • 7
  • 20
  • I've tried to do this and it doesn't work. I tried starting it with activator and with sbt, and neither picked up the option – redeagle47 Feb 08 '16 at 03:35
  • 1
    This solution is solely for starting applications via Activator Web UI (`activator ui`). If you want to change the port when using sbt or activator command line just add `-Dhttp.port=` to your command (e.g. `activator run -Dhttp.port=8080`) – Alexander B Feb 09 '16 at 08:46
0

Just a short note concerning the run command (tested with Play! 2.4):

At least on Windows activator run -Dhttp.port=80 does NOT work, but activator (hit enter) and then run -Dhttp.port=80 works

  • You'll have to use quotes when passing parameters to activator (or sbt): `activator "run -Dhttp.port=80"`, otherwise each parameter is assumed to be a task and run separately. When running the activator (or sbt) console, you can omit the quotes. – patch Oct 26 '16 at 17:25
0

Try this out:

activator "run 9500"

in terminal from your project folder.

RevakoOA
  • 601
  • 1
  • 9
  • 20
0

This command work for me guys:

activator "~run 3333"