java.net.BindException:无法分配请求的地址 [英] java.net.BindException: Cannot assign requested address
问题描述
我想在我的应用程序中使用低端口(Spring Web + Tomcat7上的SNMP陷阱接收器)。正如我在这个帖子中所说的绑定低在Ubuntu Server上的端口到Java程序之前,我收到错误权限被拒绝。然后我将tomcat7用户组更改为root。但在那之后,我得到了java.net.BindException:无法分配请求的地址错误。对于我尝试的每个端口(低端口或高端口),我总是遇到此错误。
I want to use low port in my application (SNMP Trap Receiver on Spring web + Tomcat7). As I told in this thread Binding Low Port to Java Program on Ubuntu Server, before, I got error Permission denied. Then I change tomcat7 user group be root. But after that, I got java.net.BindException: Cannot assign requested address error. For every port that I try (low or high port), I always got this error.
我检查端口是否已使用,我看到该端口仍然空闲。
我检查我的/ etc / host内容,它是这样的:
I check if the port has used, I see that the port still free. I check my /etc/host content, it is like this:
127.0.0.1 localhost
127.0.1.1 test-server
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
124.81.xx.x test-server.com
note :我的操作系统是ubuntu服务器
note: my OS is ubuntu server
推荐答案
你应该绑定到 0.0.0.0
而不是尝试指定本地地址。
You should bind to 0.0.0.0
instead of trying to specify a local-address.
这篇关于java.net.BindException:无法分配请求的地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!