Android Web app automation : Failed to start an Appium session, err was: Error: connect ECONNREFUSED

Hello,

I am trying to automate webapps on Android devices using appium.

Configuration:
Appium:V1.3.7
Android version 5.0

Code :AndroidDriver dr;
WebDriverWait myWaitVar;

	DesiredCapabilities capa = new DesiredCapabilities();
	
	capa.setCapability("deviceName", "Android");
	capa.setCapability("browserName", "Chrome");
	capa.setCapability("platformName", "Android");
	capa.setCapability("platformVersion", "5.0");
	
	try {
		dr = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capa);
		System.out.println("in the session");
		dr.get("www.google.com");
		
}
	catch (MalformedURLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}

Error :
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: connect ECONNREFUSED)”,“code”:“ECONNREFUSED”,“errno”:“ECONNREFUSED”,“syscall”:“connect”,“origValue”:“connect ECONNREFUSED”},“sessionId”:null}

Attaching Appium logs with this post.
Please helplogs.txt (7.6 KB)

Looks like, for some reason you cannot connect to the appium server.

Thanks Sebv.

Does this problem occur in case there is some issue with Appium/Chrome Driver/Chrome browser in the smartphone i am using ? what do you think ?

No I think you just cannot reach “http://127.0.0.1:4723”, you can also see in the appium log if your request ever reaches the appium server.

Hi @sebv and @AppiumUser ,

I believe the problem is not happening with "you just cannot reach “http://127.0.0.1:4723”, "… because the log (attached below by AppiumUser) is clearly shown that it is running on the same port , You just check with your Url.

Thanks,
Vijay Bhaskar.

Hi @AppiumUser,

Please make sure that your Url should be starts with http protocol -> dr.get(“www.google.com”); should be dr.get(“https://www.google.co.in/”);, The Appium Remote Url if fine with pot num 4723. and make change “deviceName” as your device’s Name displayed in settings (if possible, if not then no problem).

Please have a try, hope will helps to resolve and let me know the result.

Thanks,
Vijay Bhaskar.

Yeah sorry @AppiumUser, missed the log. This is an issue with Chromedriver not starting.

1 Like

Hi Bhaskar,

Thanks for the reply. I tried changing URL.Also have mentioned path of chromedriver.exe in the system variable PATH. Still the issue is occuring. logs with this post attached.logs_06042015.txt (7.9 KB)

Hi @AppiumUser ,

Did you changed your deviceName capability? Please let me know.

Regards,
Bhaskar.

If you are able to do some debugging, the place to look is under node_modules/appium-chromedriver/lib/chromedriver.js line 58. Try to figure out whay th spawn fails.

Hi Bhaskar,
I am now getting different logs.
Recentaly i upgraded Appium to 1.4.0 .

but still no success.

Starting Node Server
warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade!
info: Welcome to Appium v1.4.0 (REV 8f63e2f91ef7907aed8bda763f4e5ca08e86970a)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {“address”:“127.0.0.1”,“noReset”:true,“logNoColors”:true,“platformName”:“Android”,“platformVersion”:“18”,“automationName”:“Appium”}
info: Console LogLevel: debug
info: → POST /wd/hub/session {“desiredCapabilities”:{“platformVersion”:“5.0”,“platformName”:“Android”,“deviceName”:“Android”,“browserName”:“chrome”,“udid”:“4d00c1e65bb9a0c1”}}
info: Client User-Agent string: Apache-HttpClient/4.3.2 (java 1.5)
info: Set mode: Proxying straight through to Chromedriver
info: [debug] Looks like we want chrome on android
info: [debug] Creating new appium session 564c0e7d-c307-4230-8797-dfe82e1603ac
info: [debug] Checking whether adb is present
info: [debug] Using adb from D:\android-sdks\platform-tools\adb.exe
info: [debug] Using fast reset? false
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it’s already on the device
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices…
info: [debug] executing cmd: D:\android-sdks\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device 4d00c1e65bb9a0c1
info: [debug] Setting device id to 4d00c1e65bb9a0c1
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: D:\android-sdks\platform-tools\adb.exe -s 4d00c1e65bb9a0c1 wait-for-device
info: [debug] executing cmd: D:\android-sdks\platform-tools\adb.exe -s 4d00c1e65bb9a0c1 shell “echo ‘ready’”
info: [debug] Starting logcat capture
info: [debug] Set chromedriver binary as: C:\Program Files\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe
info: Set chromedriver binary as: C:\Program Files\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe
info: [debug] Pushing unlock helper app to device…
info: [debug] executing cmd: D:\android-sdks\platform-tools\adb.exe -s 4d00c1e65bb9a0c1 install “C:\Program Files\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk”
info: [debug] executing cmd: D:\android-sdks\platform-tools\adb.exe -s 4d00c1e65bb9a0c1 shell “dumpsys window”
info: [debug] Screen already unlocked, continuing.
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: D:\android-sdks\platform-tools\adb.exe -s 4d00c1e65bb9a0c1 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device…
info: [debug] executing cmd: D:\android-sdks\platform-tools\adb.exe -s 4d00c1e65bb9a0c1 push “C:\Program Files\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar” /data/local/tmp/
info: Starting App
info: [debug] Attempting to kill all ‘uiautomator’ processes
info: [debug] Getting all processes with ‘uiautomator’
info: [debug] executing cmd: D:\android-sdks\platform-tools\adb.exe -s 4d00c1e65bb9a0c1 shell “ps ‘uiautomator’”
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: D:\android-sdks\platform-tools\adb.exe -s 4d00c1e65bb9a0c1 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.android.chrome -e disableAndroidWatchers false
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] [BOOTSTRAP] [debug] Loading json…
info: [debug] Pushing command to appium work queue: [“getDataDir”,{}]
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“getDataDir”,“params”:{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:“/data/local/tmp”}
info: [debug] dataDir set to: /data/local/tmp
info: Killing any old chromedrivers, running: FOR /F “usebackq tokens=5” %a in (netstat -nao ^| findstr /R /C:"9515 ") do (FOR /F “usebackq” %b in (TASKLIST /FI "PID eq %a" ^| findstr /I chromedriver.exe) do (IF NOT %b==“” TASKKILL /F /PID %a))
info: No old chromedrivers seemed to exist
info: Spawning chromedriver with: C:\Program Files\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe --url-base=wd/hub --port=9515
info: [CHROMEDRIVER STDOUT] Starting ChromeDriver 2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3) on port 9515
Only local connections are allowed.
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: Proxying [GET /status] to [GET http://127.0.0.1:9515/wd/hub/status] with no body
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Could not proxy command to remote server. Original error: connect ECONNREFUSED
info: [debug] Error: Could not proxy command to remote server. Original error: connect ECONNREFUSED
at JWProxy.proxy$ (lib/proxy.js:121:13)
at tryCatch (C:\Program Files\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Program Files\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\babel-runtime\regenerator\runtime.js:231:22)
at GeneratorFunctionPrototype.Gp.(anonymous function) [as throw] (C:\Program Files\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\babel-runtime\regenerator\runtime.js:264:19)
at tryCatch (C:\Program Files\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.step (C:\Program Files\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\babel-runtime\regenerator\runtime.js:116:22)
at lib$es6$promise$$internal$$tryCatch (C:\Program Files\Appium\node_modules\appium\node_modules\es6-promise\dist\es6-promise.js:319:16)
at lib$es6$promise$$internal$$invokeCallback (C:\Program Files\Appium\node_modules\appium\node_modules\es6-promise\dist\es6-promise.js:331:17)
at lib$es6$promise$$internal$$publish (C:\Program Files\Appium\node_modules\appium\node_modules\es6-promise\dist\es6-promise.js:302:11)
at lib$es6$promise$$internal$$publishRejection (C:\Program Files\Appium\node_modules\appium\node_modules\es6-promise\dist\es6-promise.js:252:7)
at Object.lib$es6$promise$asap$$flush [as _onImmediate] (C:\Program Files\Appium\node_modules\appium\node_modules\es6-promise\dist\es6-promise.js:113:9)
at processImmediate [as _immediateCallback] (timers.js:330:15)
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Could not proxy command to remote server. Original error: connect ECONNREFUSED)”,“origValue”:“Could not proxy command to remote server. Original error: connect ECONNREFUSED”},“sessionId”:null}
info: ← POST /wd/hub/session 500 27770.448 ms - 278

Hi,

Please try with the following code,may helps you !!!

AndroidDriver driver;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, “Android”));
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION,“5.0.2”);
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, “Galaxy SIII”);// or ANDROID
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, “Chrome”);
driver = new AndroidDriver(new URL(“http://0.0.0.0:4723/wd/hub”), capabilities);

driver.get(“https://www.google.co.in/”);
/* Perform your actions */.

Regards,
Bhaskar.

No it dint help. Same logs. I just wonder about the line from code
Looks like we want chrome on android … does this mean i dont have Chrome on my device ?

HI,
No…it is saying about currently doing Web App automation on Chrome…Thats it.(if you are automating Hybrid App it will show app required or something else…) .Nothing is wrong with that…!!!
And i’m also getting the below warning when i was upgraded to latest appium version
** " Starting Node Server
warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade! " **

I guess the problem with your chrome browser version (I’m not sure).Please check with others too…
Regards,
Bhaskar.

I am facing same issue… Did you find the solution?

1 Like

Yes @akrai,

I’ve found the solution that I was upgraded to node to its latest version and then re-installed appium, and got resolved.

Hope this helps…!!

Regards,
Bhaskar.

@ Bhaskar
I’m also facing the same issue with node < 0.12 and upgrade it. Please let me know how u have updated the node to its latest version and how you re-installed the appium…thanks in advance please help me out
Error as follows :
" > warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade! "
" error: No app set; either start appium with --app or pass in an ‘app’ value in desired capabilities, or set androidPackage to launch pre-existing app on device "

1 Like

what version of node and appium did u used ?
I got the same problem

The following fixed the exact same issue for me:

  1. npm uninstall -g appium;
  2. brew upgrade npm&&node;
  3. npm install -g appium