Android "Host is Unknown" Error

Go To


I'm getting an error from Android that "Host is unknown server:80". I'm trying to access a WCF Rest service on a server from Android Emulator on a virtual machine. Is this scenario supported? BTW, I can access the help page of the service, so I know the service is working. And I can access it from that virtual machine.

Any help is appreciated. My development environment is Windows 7 64 BIT, using latest Eclipse version. The services is on a Win 2008 R2 machine.

2012-04-04 01:38
by Brian Mains
Q: Exactly how many hosts are have you got? You've got your Win7 development PC and your Win2008 server. And your Android emulator. Is the emulator running directly on your Win7 PC, or is there some other VM in the mix - paulsm4 2012-04-04 01:45
Q: Can you see your Win2008 server in your Android emulator's web browser (this would be the equivalent of "can the Android emulator "ping" the Windows server) - paulsm4 2012-04-04 01:46
Q: Do things work if you set your WCF endpoint address to the server's IP address (instead of the server's name) - paulsm4 2012-04-04 01:47
Any error going along the lines of 'host is unknown' is likely DNS related. Are you using host names or IP addresses to connect to the service? Can you access the help for the service from the Android emulator itself - Ariel 2012-04-04 01:42
@Ariel I'm using the host name; I'll double check whether I can access it from the emulator. That's a great idea - Brian Mains 2012-04-04 11:49
@paulsm4 1 Win 2008 server hosting a WCF rest service, which I have a Win 7 64 bit virtual where the android emulator is. I'm going to double check whether the browser can hit it; didn't think of that. I also haven't tried IP, which is something I'll also try to do. Thanks - Brian Mains 2012-04-04 11:49
@Ariel I cannot access the help page... - Brian Mains 2012-04-05 00:31


I had to use the alternative IP since the emulator uses the localhost IP.

2012-12-07 13:58
by Brian Mains


My guess is that you have incorrectly configured the hostname.

Based on the error message, it looks as if you have supplied ":80" as a hostname or IP address. If the platform thought that that string was supposed to be a DNS name and tried to do a DNS lookup, and the lookup would fail resulting in a "unknown host" diagnostic of some kind.

If this is what the problem is, then there are a couple of observations.

  • If you are trying to refer to "this device" in a static config file (or whatever), you can use its hostname or IP address (if you know them), or the IP address of the loopback interface which is (most likely) "". An empty String probably won't work.

  • The port number (e.g. "80") should not be included in a hostname / IP address ... unless you are parsing it out before you do the host string resolution.

2012-04-04 02:08
by Stephen C
"Name resolution" (e.g. DNS) is the likeliest culprit. That's why I asked if the OP could browse to his server host (or "ping" it). But if he's on running on a VM (a VM besides the Android emulator), then networking might also be an issue. IMHO.. - paulsm4 2012-04-04 02:15
@paulsm4 - I'm assuming that the BIG CLUE in the error message is not a red herring - Stephen C 2012-04-04 02:22
@paulsm4 I actually have not supplied :80; it inferred that. I'm just referring to it as http:///myservicevirtualdirectory I'll try by IP too - Brian Mains 2012-04-04 11:47
@StephenC I goofed; the server name is there, but in my post I did it as , so the server part got stripped out - Brian Mains 2012-04-05 00:21


Once potential cause of this error is forgetting to include the internet permission or not putting it in the right place. Make sure you have the following in your manifest.xml, outside of the application tags:

<uses-permission android:name="android.permission.INTERNET"/>
2012-04-04 02:45
by elevine
I do have that permission set. I'll double check that it's outside the application tags.. - Brian Mains 2012-04-04 11:46
This is my file in order:

Brian Mains 2012-04-05 00:22

That looks right, I don't think the permissions are the cause of your problem - elevine 2012-04-05 01:08