This question already has answers here:
InetAddress.getLocalHost() throws UnknownHostException
                                
                                    (9个答案)
                                
                        
                                3个月前关闭。
            
                    
专用的Linux服务器抛出UnknownHostException。

InetAddress addr;
    try {
        addr = InetAddress.getLocalHost();
    } catch (UnknownHostException e) {
        throw new InstantiationError("cannot find hub ip");
    }

最佳答案

您可能在localhost(win)system32\drivers\etc\hosts(linux)中没有/etc/hosts的映射

10-07 22:28