code: private static InetAddress findNonLoopbackAddress() throws SocketException {
          final Enumeration<NetworkInterface> enumInterfaceAddress = NetworkInterface.getNetworkInterfaces();
          while (enumInterfaceAddress.hasMoreElements()) {
              final NetworkInterface netIf = enumInterfaceAddress.nextElement();
  
              // Iterate over inet address
              final Enumeration<InetAddress> enumInetAdress = netIf.getInetAddresses();
              while (enumInetAdress.hasMoreElements()) {
                  final InetAddress address = enumInetAdress.nextElement();
                  if (!address.isLoopbackAddress()) {
                      return address;
                  }
              }
          }
          return null;
      }
docs: Find a non loopback address for this machine on which to start the server.
  @return a non loopback address
  @throws SocketException if a socket error occurs