Error Connecting to Android Emulator

I am automating an Mobile web application using Android Emulator in MAC machine.

Machine settings :
MAC OS : 10.9.5
Appium : 1.4 (Draco)
Browser : Android Browser

Appium Status is (http://127.0.0.1:4444/wd/hub/status)
{“status”:0,“value”:{“build”:{“version”:“1.4.8”,“revision”:“c8179bd8352d3c62d98fa58b324491230df9342a”}}}

My Capabilities settings are :

capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, “Android”);
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, “Browser”);
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, “4.4.2”);
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, “KitKatDevice1”); //Emulator Name
url = new URL(“http://127.0.0.1:4444/wd/hub”);

I am getting the below error in appium server while execution the test case.

error: Unhandled error: Error: getaddrinfo ENOTFOUND localhost
at errnoException (dns.js:44:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26) context: [POST /wd/hub/session {“desiredCapabilities”:{“platformVersion”:“4.4.2”,“deviceName”:“KitKatDevice1”,“platformName”:“Android”,“browserName”:“Browser”}}]

Please let me know about this error message and how to resolve it.

1 Like

Please someone help me on this.

I no this is so funny ,
But just try to change ur port to 4723

        driver = new RemoteWebDriver (new Uri("http://127.0.0.1:4723/wd/hub"), capabilities);

I have tried changing the port no, but i face the same issue.

Hi @jlipps

Can you help us on this.

AppiumDriver driver;
driver = new AndroidDriver (new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

@Chathura_Dhanushka, @babu_shaik,

I have tried all this too. The mentioned capabilities works fine in Windows machine. But the same capabilities didn’t work for MAC Machine.

Can you help me on this.

I have the same issue if I want to connect with an Android emulator on a Mac computer.
Version 1.4.8 (Draco)

info: [debug] Getting connected emulators

error: Unhandled error: Error: getaddrinfo ENOTFOUND localhost
at errnoException (dns.js:44:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26) context: [POST /wd/hub/session {“desiredCapabilities”:{“platformName”:“Android”,“platformVersion”:“4.3”,“newCommandTimeout”:“999999”,“automationName”:“Appium”,“deviceName”:“test2”}}]

Seems like a nodejs issue?

I have the same problem when I run the test on windows work perfect. But when I run the test on mac not working. I need help please, eh read all the forums trying to find the problem.

Can someone help me on this, even i am facing the same problem

I get the following error:

error: Unhandled error: Error: getaddrinfo ENOTFOUND localhost at errnoException (dns.js:44:10) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26) context: [POST /wd/hub/session {“desiredCapabilities”:{“appPackage”:“com.sabm.mast”,“app”:"/Users/sudhir.pandit/Documents/workspace/Learning/src/Mast_sab.apk",“platformName”:“Android”,“deviceName”:“071ce659018966d9”,"newCommandTime]

I am using MAC 10.9.4 and Appium version 1.3.7
Using actual device and not emulator

Try by changing the below line of code
driver = new AndroidDriver (new URL(“http://0.0.0.0:4723/wd/hub”), capabilities);

The issue is with host file.

Both IP address 127.0.0.1 and 0.0.0.0 should be enabled in the host file.

Thanks everyone for the help.