I'm trying to run my Scala code with SBT, but get the error below. This happens both with SBT using the command line and with IntelliJ Idea.
[error] (run-main) org.jboss.netty.channel.ChannelException:
Failed to bind to: /127.0.0.1:80
org.jboss.netty.channel.ChannelException: Failed to bind to: /127.0.0.1:80
....
....
Caused by: java.net.SocketException: Permission denied
What do I configure to allow port access. This happens both when I try to run on my local Mac and on my remote Ubuntu server.
Running sbt with "sudo sbt" fixes the problem, but this is not the solution. Where can I set permission to allow my Scala app to access port 80.
The solution to this problem will depend on the operating system, not on anything that SBT, Scala or Java might do.
For instance, Debian proposes three different solutions, all of which can be used on other Linux distributions -- two of them are variations on running as root, and the third uses iptables to fake listening on port 80.
On FreeBSD one can disable the low port limitation entirely, and Solaris can do so per-port-and-user, as described (for both) here.
Running sbt with "sudo sbt" fixes the problem, but this is not the solution. Where can I set permission to allow my Scala app to access port 80.
I think that is your only solution, though. Only privileged applications can bind to ports under 1024.
Maybe you are more comfortable with running an http proxy on port 80 (only the proxy as root), or have some ipfilter rule that re-routes incoming port 80 to port 8080 ? See also this answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With