The security.properties file in Java 11 (and later) have a new configuration:
# The categories are: # # hostInfo - IOExceptions thrown by java.net.Socket and the socket types in the # java.nio.channels package will contain enhanced exception # message information # # The property setting in this file can be overridden by a system property of # the same name, with the same syntax and possible values. # #jdk.includeInExceptions=hostInfo As noted for that property, if hostInfo is set as a value for this jdk.includeInExceptions then IOException thrown by java.net.Socket will container additional information. Is this expected to work for all kinds of connection issues related to Socket types? For example, I have a Java program which creates a ServerSocket and (intentionally) binds it to port which is already in use. I (as expected) keep seeing this exception: Exception in thread "main" java.net.BindException: Address already in use (Bind failed) at java.base/java.net.PlainSocketImpl.socketBind(Native Method) at java.base/java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:436) at java.base/java.net.ServerSocket.bind(ServerSocket.java:381) at java.base/java.net.ServerSocket.bind(ServerSocket.java:335) at Bind.main(Bind.java:7) However, even after setting the jdk.includeInExceptions=hostInfo, I haven't been able to generate the host name and port against which this BindException occurs. Is this part of the code, in the JDK, expected to include this additional info for this exception? P.S: Tried with both Java 11 and Java 14. -Jaikiran