MAUI Android Emulator networking exception - can't resolve hostname

Tony Nicholls 26 Reputation points
2022-08-03T21:46:19.827+00:00

So I have a MAUI application that I'm trying to debug using an Android Pixel 5 emulator.

It contains a call to an external URL (https://ts-restapi-dev.greatideaz.com) that it claims that it can't resolve to its IP address (20.116.90.125)

I run the same code in Windows and it works. Run the same code on a physical Android device and it works....

Just fails on the android emulator :(

Any ideas - I'm assuming that the emulator networking isn't correctly set up but I have the latest 17.3 preview with the latest version of the emulators.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,412 questions
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 42,001 Reputation points Microsoft Vendor
    2022-08-05T06:30:32.12+00:00

    Hello,

    So the question is how does the emulator figure out DNS - is there something I need to setup there?

    Referring to this official documentation Configuring the emulator DNS settings, you could find the recommended way to configure the emulator DNS settings is the following content:

    When starting the emulator at the command line, you can also use the -dns-server <serverList> option to manually specify the addresses of DNS servers to use, where <serverList> is a comma-separated list of server names or IP addresses. You might find this option useful if you encounter DNS resolution problems in the emulated network (for example, an "Unknown Host error" message that appears when using the web browser).

    Due to you have resolved your issue by adding an entry to your laptop's hosts file, you could choose not to manually set up dns.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.