Java.net.BindException: Unable to assign the requested address, java.io.IOException: Too many open files

I am getting java.net.BindException: Can't assign the requested address and if this exception is thrown I try to bind it again with the same port and host. But after some attempt at linking, I get java.io.IOException: Too many open files.

Stack trace:

    java.net.BindException: Cannot assign requested address
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:444)
    at sun.nio.ch.Net.bind(Net.java:436)
    at sun.nio.ch.SctpServerChannelImpl.bind(SctpServerChannelImpl.java:109)
    at com.sun.nio.sctp.SctpServerChannel.bind(SctpServerChannel.java:184).

      

and after some rejection:

    java.io.IOException: Too many open files
    at sun.nio.ch.IOUtil.makePipe(Native Method)
    at sun.nio.ch.EPollSelectorImpl.<init>(EPollSelectorImpl.java:65)
    at sun.nio.ch.EPollSelectorProvider.openSelector(EPollSelectorProvider.java:36)
    at java.nio.channels.Selector.open(Selector.java:227)

      

Is it possible that FD stays open when java.net.BindException: cannot assign the requested address?

+3


source to share


3 answers


This is usually an OS level issue. See how to increase the number of files you can open. On linux, the parameter is located in /etc/security/limits.conf:



UID soft nofile 4096 UID hard nofile 10240

0


source


Is it possible that FD stays open when java.net.BindException: cannot assign the requested add?

Yes. You have to close the outlet yourself. Obviously you have a socket leak.



I see no point in repeating the binding. It will fail anyway. Probably the problem with the original bind is also related to the socket leak.

0


source


maybe ip problems got into / etc / hosts and changed it to

0


source







All Articles