Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change HTTP port that Play2 is listening on

The documentation says:

$ play start

Note: the HTTP port can be set by passing -Dhttp.port system variable

but I'm still hitting 9000 port taken error

$ /opt/play-2.0/play start -Dhttp.port=9001

[info] Loading project definition from /my/path
[info] Set current project to marmurka (in build file:/my/path/)

(Starting server. Type Ctrl+D to exit logs, the server will remain in background)

Play server process ID is 27505
[info] play - Application started (Prod)
Oops, cannot start the server.
org.jboss.netty.channel.ChannelException: Failed to bind to: /0.0.0.0:9000
    at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:298)
    at play.core.server.NettyServer.<init>(NettyServer.scala:63)
    at play.core.server.NettyServer$.createServer(NettyServer.scala:131)
    at play.core.server.NettyServer$$anonfun$main$5.apply(NettyServer.scala:153)
    at play.core.server.NettyServer$$anonfun$main$5.apply(NettyServer.scala:152)
    at scala.Option.map(Option.scala:133)
    at play.core.server.NettyServer$.main(NettyServer.scala:152)
    at play.core.server.NettyServer.main(NettyServer.scala)
Caused by: java.net.BindException: Address already in use
    at sun.nio.ch.Net.bind(Native Method)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:137)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:77)
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.bind(NioServerSocketPipelineSink.java:140)
    at     org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.handleServerSocket(NioServerSocketPipelineSink.java:92)
    at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.eventSunk(NioServerSocketPipelineSink.java:66)
    at org.jboss.netty.channel.Channels.bind(Channels.java:462)
    at org.jboss.netty.channel.AbstractChannel.bind(AbstractChannel.java:186)
    at org.jboss.netty.bootstrap.ServerBootstrap$Binder.channelOpen(ServerBootstrap.java:343)
    at org.jboss.netty.channel.Channels.fireChannelOpen(Channels.java:170)
    at org.jboss.netty.channel.socket.nio.NioServerSocketChannel.<init>(NioServerSocketChannel.java:77)
    at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.newChannel(NioServerSocketChannelFactory.java:137)
    at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.newChannel(NioServerSocketChannelFactory.java:85)
    at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:277)
    ... 7 more
like image 838
Wojtek Erbetowski Avatar asked Mar 30 '12 11:03

Wojtek Erbetowski


People also ask

How do I change the port number in play framework?

We are using Play version 2.5. 6. For changing the port, go to your project root folder and hit: activator "run 8008" in command prompt / terminal. and that's it.

What is the default port for Play application?

Overriding configuration with system properties The default is to listen on port 9000 at the 0.0. 0.0 address (all addresses).


2 Answers

First type: play

then in console type: start 9001

The same for development mode. First: play, then: run 9001

Another way use qoutes:

play "start 9001"

play "run 9001"

like image 59
Oleg Avatar answered Sep 22 '22 05:09

Oleg


Also note that the server remains in the background, Ctrl+D does not kill it (though it does if you use run instead of start). So if you are wondering why the port is still in use... that's probably the reason.

like image 41
Robin Green Avatar answered Sep 20 '22 05:09

Robin Green