java.net.UnknownHostException:server:local的主机名无效 [英] java.net.UnknownHostException: Invalid hostname for server: local
问题描述
我应该采取哪些步骤来解决错误:
What are the steps I should take to solve the error:
java.net.UnknownHostException: Invalid hostname for server: local
我在Android模拟器中添加了新的虚拟主机名,但结果返回到
I added the new virtual host name at Android emulator but the result returns to
java.net.UnknownHostException virtualhostname at
java.net.InetAddress.lookUpHostByName(InetAddress.java:506)
当我在我的电脑上输入虚拟主机URL时,它可以显示。然后,当我在Emulator上运行并检查Logcat时,如果200,202或错误代码编号,我无法读取或检查HTTP状态。它只是返回 UnknownHostException
When I type my virtualhost URL on my PC, it works on display. Then again, when I ran on Emulator and check on Logcat, I couldn't be able to read or check the HTTP status if 200, 202, or an error code number. It simply returned to UnknownHostException
推荐答案
真正的例外是什么没有名为local的已知服务器。我的猜测是你正在尝试连接到本地计算机。请尝试使用主机名localhost
,或者 127.0.0.1
或 :: 1
(最后一个是IPv6)。
What the exception is really saying is that there is no known server with the name "local". My guess is that you're trying to connect to your local computer. Try with the hostname "localhost"
instead, or perhaps 127.0.0.1
or ::1
(the last one is IPv6).
来自 javadocs :
抛出以表示无法确定主机的IP地址
。
Thrown to indicate that the IP address of a host could not be determined.
127.0.0.1
或 :: 1
或localhost
应该始终是loopback接口,所以如果没有工作我真的很惊讶。
127.0.0.1
or ::1
or "localhost"
should always be the loopback interface, so if that doesn't work I'd be really surprised.
如果您的网络上确实有一台名为本地的服务器 - 检查您的DNS设置或将其添加到您的主机文件。
If there really is a server called "local" on your network - examine your DNS settings or add it to your hosts file.
这篇关于java.net.UnknownHostException:server:local的主机名无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!