How do I change the default port (9000) that Play

2019-01-02 21:45发布

How can I change the default port used by the play framework in development mode when issueing the "run" command on the play console.

This is for playframework 2.0 beta.

Using the http.port configuration parameter either on the command line or in the application.conf seems to have no effect:

C:\dev\prototype\activiti-preso>play run --http.port=8080
[info] Loading project definition from C:\dev\prototype\activiti-preso\project
[info] Set current project to activiti-preso (in build file:/C:/dev/prototype/activiti-preso/)


Windows, really? Ok, disabling colors.

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

[error] org.jboss.netty.channel.ChannelException: Failed to bind to: 0.0.0.0/0.0.0.0:9000
[error] Use 'last' for the full log.

19条回答
Emotional °昔
2楼-- · 2019-01-02 22:13

I did this. sudo is necessary.

$ sudo play debug -Dhttp.port=80
...
[MyPlayApp] $ run

EDIT: I had problems because of using sudo so take care. Finally I cleaned up the project and I haven't used that trick anymore.

查看更多
等我变得足够好
3楼-- · 2019-01-02 22:15

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
查看更多
干净又极端
4楼-- · 2019-01-02 22:17

Play 2.2.0 on Windows

Using a zip distribution (produced using the "dist" command), the only way I was able to change the startup port was by first setting JAVA_OPTS and then launching the application.

E.g., from the command line

set JAVA_OPTS=-Dhttp.port=9002
bin\myapp.bat

where myapp.bat is the batch file created by the "dist" command.

The following would always ignore my http.port parameter and attempt to start on the default port, 9000

bin\myapp.bat -Dhttp.port=9002

However, I've noticed that this works fine on Linux/OSX, starting up on the requested port:

./bin/myapp -Dhttp.port=9002
查看更多
可以哭但决不认输i
5楼-- · 2019-01-02 22:18

We cannot change the application port from the avtivator but can change from the command line activator "~run 8080"

But to run on the poet 9000 from the activator we need to stop the application which is using this port. We can use the this application to find this and end the process https://technet.microsoft.com/en-in/sysinternals/bb897437.aspx

After this we can run and it will be successful.

查看更多
劳资没心,怎么记你
6楼-- · 2019-01-02 22:20

From the play console, you just need to type run 8888, if you want to run it from port 8888.

play> run 8888
查看更多
孤傲高冷的网名
7楼-- · 2019-01-02 22:21

On Windows maybe the play "run 9001" will not work. You have to change the play.bat file. See Ticket

查看更多
登录 后发表回答