code: public static String localHostName() {
          try {
              InetAddress localhost = InetAddress.getLocalHost();
              return localhost.getHostName();
          } catch (Exception e) {
              InternalLogFactory.getLog(AwsHostNameUtils.class)
                  .debug(
                      "Failed to determine the local hostname; fall back to "
                              + "use \"localhost\".", e);
              return "localhost";
          }
      }
docs: Returns the host name for the local host. If the operation is not allowed
  by the security check, the textual representation of the IP address of
  the local host is returned instead. If the ip address of the local host
  cannot be resolved or if there is any other failure, "localhost" is
  returned as a fallback.