How do I change the default port (9000) that Play uses when I execute the "run" command?
Play 2.x
In Play 2, these are implemented with an sbt plugin, so the following instructions are really just sbt tasks. You can use any sbt runner (e In Play 2, these are implemented with an sbt plugin, so the following are really just sbt tasks. You can use any sbt runner (e.g.
sbt
,play
, oractivator
). Below thesbt
runner is used, but you can substitute it for your sbt runner of choice.
Play 2.x - Dev Mode
For browser-reload mode:
sbt "run 8080"
For continuous-reload mode:
sbt "~run 8080"
Play 2.x - Debug Mode
To run in debug mode with the http listener on port 8080
, run:
sbt -jvm-debug 9999 "run 8080"
Play 2.x - Prod Mode
Start in Prod mode:
sbt "start -Dhttp.port=8080"
Play 2.x - Staged Distribution
Create a staged distribution:
sbt stage
For Play 2.0.x and 2.1.x use the target/start
script (Unix Only):
target/start -Dhttp.port=8080
For Play 2.2.x & 2.3.x use the appropriate start script in the target/universal/stage/bin
directory:
target/universal/stage/bin/[appname] -Dhttp.port=8080
With Play 2.2.x & 2.3.x on Windows:
target\universal\stage\bin\[appname].bat -Dhttp.port=8080
Play 2.x - Zip Distribution
To create a zip distribution:
sbt dist
For Play 2.0.x and 2.1.x use the start
script (Unix Only) in the extracted zip:
start -Dhttp.port=8080
For Play 2.2.x use the appropriate script in the [appname]-[version]/bin
directory:
[appname]-[version]/bin/[appname] -Dhttp.port=8080
With Play 2.2.x on Windows:
[appname]-[version]\bin\[appname].bat -Dhttp.port=8080
Play 1.x
Change the http.port
value in the conf/application.conf
file or pass it command line:
play run --http.port=8080
Play 2.0-RC4
It is important to include quotes around the play command you want to run. In my case without the quotes play would still run on port 9000.
play "run 8080"
Alternatively you could run the following from the play console (type 'play' to get to the console)
run 8080
Hope this helps someone.
via sbt settings:
...
.settings(PlayKeys.playDefaultPort := 8855)
...