can't start play! server on ec2 (play! framework)
recently i have created a new ec2 instances (quick launch ) and i tried to deploy my Play! application the security group gives access to port 80 and port 22 (SSH) but when i run :
play start 80
it gives me this
[error] org.jboss.netty.channel.ChannelException: Failed to bind to: /0.0.0.0:80
[error] Use 'last' for the full log.
which means that the 80 port is used when i run
netstat -tlnp
i get
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3692/sendmail
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3653/sshd
tcp 0 0 :::22 :::* LISTEN 3653/sshd
i've searched all the web but i didn't figure it out, help me please !
NOTE : i just solve this all i have to do is start it with sudo.
Solution 1:
Since you're binding to a port below 1024, it must be started with root privileges.
Try something like:
sudo play start 80
Solution 2:
To deploy on EC2 you should create a standalone version of your application in your local machine using:
play dist
Then you copy the generated .zip to your EC2 instance using scp, unzip it using unzip.
You would then want to run your application like so:
sudo nohup yourAppName-version/bin/yourAppName -Dhttp.port=80
sudo in order to be able to bind to a port below 1024.
nohup in order to be able to exit the ssh session without sending the HUP signal to your play app.
yourAppName-version/bin/yourAppName replaced with YOUR app's name & version should be where your script is.
-Dhttp.port is the option to bind to a given port.
Additional Info: You should consider adding -J-Xms128M -J-Xmx512m to avoid RAM allocation problems (I use micro instances, adjust to your needs).