Protocol handler start failedCaused by: java.net.SocketException: Permission denied

最近在使用mac启动项目的时候,发现原本在Windows下正常跑的项目报错如下:

Protocol handler start failedCaused by: java.net.SocketException: Permission denied

一模一样的代码,Windows下正常运行,但在mac上面却报错了,实在让人不解,所以这篇文章记录下解决的方案。


查找原因

经过Google发现,stackflow上面已经有大牛回答了这个问题,直接贴过来看看

Linux doesn’t allow a normal user to bind to a TCP port that’s <= 1024. There’s a discussion of the reasons for that here. You’re attempting to bind to 86 and, therefore, it’s failing with “Permission denied”. The quickest and safest solution is to configure the port with a value that’s > 1024.
As you’re using Boot’s embedded Tomcat instance, the port’s configured in application.propertiesusing the server.port property.

翻译过来就是说:

Linux不允许普通用户绑定到<= 1024 \的TCP端口。 有一个讨论原因[这里](https://unix.stackexchange.com/questions/16564/why-are-the-first-1024-ports-restricted-to-the-root-user-only)。 你试图绑定到80,因此它失败了“权限被拒绝”。 最快和最安全的解决方案是使用大于1024的值配置端口。当您使用Boot的嵌入式Tomcat实例时,使用server.port属性在application.properties中配置端口。

总结

好了,原因找到了,原来在linux下,为了系统安全,使用小于1024端口时,需要被授权,最快的解决方案就是更换一个大于1024的端口。ok,直接把端口号更改为8080,重启,问题解决。

  • 10
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值