Oleg
Oleg

Reputation: 3200

play framework listen on localhost

Is it possible to start play framework 2.3 on localhost ? I have tried

./activator run -Dhttp.address=127.0.0.1 -Dhttp.port=9007

./activator run -Dhttp.address=localhost -Dhttp.port=9007 # From 

another stackoverflow thread ./activator start -Dhttp.address=127.0.0.1 -Dhttp.port=9007

But nothing works everytime I am receiving

[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9007

related thread Force Play Framework to listen on localhost only

Upvotes: 3

Views: 4003

Answers (4)

pilcrow
pilcrow

Reputation: 11

Instead of: ./activator run -Dhttp.address=127.0.0.1 -Dhttp.port=9007

reverse the arguments ("-D" option before "run"):

activator -Dhttp.address=127.0.0.1 run

--- (Running the application, auto-reloading is enabled) ---
[info] p.c.s.NettyServer - Listening for HTTP on /127.0.0.1:9007
(Server started, use Ctrl+D to stop and go back to the console...)

Upvotes: 1

Martijn
Martijn

Reputation: 2326

According to the documentation provided by Play Framework the way you're going at it only works for Netty based instances of Play. I presume you are using Akka-Http, if you're not however, please report this as a bug to the Play Framework team.

You might also want to read up on this, it covers on how to set Play Framework up to work behind a proxy such as Nginx or Apache.

One last thing, it is generally recommended to only expose the absolute necessary ports to the outside internet, preventing attackers from exploiting possible weak points in your system. I advice you, doesn't matter if you get this in working order or not, to also install some good IPTables software on your box and block the port your local, behind the firewall, Play instance is running on.

Upvotes: 2

Rakesh Chouhan
Rakesh Chouhan

Reputation: 1230

Try this

./activator "run 9007"

you can access your application through localhost by this. you can write any port you want in place of 9007

Upvotes: 0

acjay
acjay

Reputation: 36521

Just do activator "run 9007" (assuming activator is in your PATH, which is the norm).

See also:

Upvotes: 0

Related Questions