Ashish Agarwal Ashish Agarwal - 6 months ago 89
Java Question Invalid hostname for server: local

What are the steps I should take to solve the error - Invalid hostname for server: local

I added the new virtual host name at Android emulator but the result returns to " virtualhostname at".

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"


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 (the last one is IPv6).

From the javadocs:

Thrown to indicate that the IP address of a host could not be determined."localhost" should always be the loopback interface, so if that doesn't work I'd be really surprised.

If there really is a server called "local" on your network - examine your DNS settings or add it to your hosts file.