Getting ECONNREFUSED for one system port when parallel android tests are run

I am running parallel android tests on 2 real devices.
Here is the set up I did as per guidelines given at ( )
Appium Server: 32538 and 21867 (Launched using appium service builder class with ‘usingAnyFreePort’ method which is executed in each test class)
provided udid, system port(8205,8206) capability in both session
Appium server version: 1.11.1
Appium java client library version: 7.0.0
Test Ng xml:

<?xml version="1.0" encoding="UTF-8" ?>

< !DOCTYPE suite SYSTEM “” >
< suite name=“MAF Sample App Testing” preserve-order=“true” verbose=“1” parallel=“tests”>
< test name=“U2 Double Oven tests”>
< parameter name=“systemPort” value=“8205”/>
< classes>
< class name=“gis.sit.coreAppAutomation.APPTests1”/>
</ classes>
</ test>
< test name=“Minerva Single Tests”>
< parameter name=“systemPort” value=“8206”/>
< classes>
< class name=“gis.sit.coreAppAutomation.APPTests2”/>
</ classes>
</ test>
</ suite>
Issue: When I run above testNG xml APPTests1 runs fine at 32538 at system port 8205 but APPTests2 with system port 8206 is failing with error in appium log below

2019-08-20 10:17:56:094 [UiAutomator2] Waiting up to 30000ms for UiAutomator2 to be online…
2019-08-20 10:17:56:094 [ADB] Creating ADB subprocess with args: ["-P",5037,"-s",“92ad966a”,“shell”,“am”,“instrument”,"-w",“io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner”]
2019-08-20 10:17:58:399 [Instrumentation] io.appium.uiautomator2.server.test.AppiumUiAutomator2Server:
2019-08-20 10:17:59:098 [WD Proxy] Matched ‘/status’ to command name ‘getStatus’
2019-08-20 10:17:59:101 [WD Proxy] Proxying [GET /status] to [GET http://localhost:8206/wd/hub/status] with no body
*2019-08-20 10:17:59:105 [WD Proxy] Got an unexpected response: *
2019-08-20 10:18:00:126 [WD Proxy] Matched ‘/status’ to command name ‘getStatus’
2019-08-20 10:18:00:126 [WD Proxy] Proxying [GET /status] to [GET http://localhost:8206/wd/hub/status] with no body
2019-08-20 10:18:00:170 [WD Proxy] Got an unexpected response:
Please help here, I tried using other ports also but still one script fails with ECONNREFUSED.
Please let me know if additional information is required from my side to look into the issue.

@sanket492 i run appium server myself as process in code. like in command line. what you should do to run different tests simultaneously:

  • add to suite: thread-count=“2” (at least this in testNG. with JUnit - no idea. i see you have some ’ AndroidJUnitRunner’)
  • you should run appium server with different system + bootstrap ports
  • i did not see code of your runner, how you use driver to suggest any more

Thanks Aleksei for having a look at issue and for your reply. Here I am using testNg only not junit, I see junitrunner in logs seems appium internally uses junit.
I tried using thread count in test ng but still facing same issue.
Also want to know how to set different bootstrap ports? I set different system port as mentioned above as in desired capability.

@sanket492 look at . if you have problem reply again

@sanket492 sorry i gave wrong link. I gave driver capabilities instead of server flags

e.g. i start as:

appium --log-level error --port 5010 --bootstrap-port 5310 --command-timeout 240 --session-override --log-timestamp
1 Like

@Aleksei Thanks for sharing the info. Today I tried same code almost 20 times but I didn’t get above issue. Seems to be intermittent node server issue.