Getting Unable to connect to "http://localhost:4723/wd/hub" error with node 18 when run against mobile Apps

I have webdriverio + cucumberjs based tests and When using node 18, I,m getting error - http://localhost:4723/wd/hub
Setup:

node v18.20.3 (npm v10.7.0)
[email protected]
[email protected]

I am able to run against iOS safari browser but fails to runs against any mobile App. But my same tests works when I use node 16.

node v16.20.2 (npm v8.19.4)
[email protected]
[email protected]

Error log:

Unable to connect to "http://localhost:4723/wd/hub", make sure browser driver is running on that address.
If you use services like chromedriver see initialiseServices logs above or in wdio.log file as the service might had problems to start the driver.
    at Runtime.runTestRunHooks (/private/tmp/scratchEmNi2G.scratch/test-packagesbz9OA/node_modules/<my-package>/node_modules/@cucumber/cucumber/lib/runtime/run_test_run_hooks.js:23:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Runtime.start (/private/tmp/scratchEmNi2G.scratch/test-packagesbz9OA/node_modules/<my-package>/node_modules/@cucumber/cucumber/lib/runtime/index.js:53:9)
    at async runCucumber (/private/tmp/scratchEmNi2G.scratch/test-packagesbz9OA/node_modules/<my-package>/node_modules/@cucumber/cucumber/lib/api/run_cucumber.js:106:21) {
  jse_shortmsg: 'a BeforeAll hook errored, process exiting: node_modules/<my-package>/dist/myfile.js:72',
  jse_cause: Error: Failed to create session.
  Unable to connect to "http://localhost:4723/wd/hub", make sure browser driver is running on that address.
  If you use services like chromedriver see initialiseServices logs above or in wdio.log file as the service might had problems to start the driver.
      at startWebDriverSession (file:///private/tmp/scratchEmNi2G.scratch/test-packagesbz9OA/node_modules/<my-package>/node_modules/webdriver/build/utils.js:68:15)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async WebDriver.newSession (file:///private/tmp/scratchEmNi2G.scratch/test-packagesbz9OA/node_modules/<my-package>/node_modules/webdriver/build/index.js:26:45)
      at async remote (file:///private/tmp/scratchEmNi2G.scratch/test-packagesbz9OA/node_modules/<my-package>/node_modules/webdriverio/build/index.js:48:22),
  jse_info: {},
  cause: [Function: ve_cause]

Might be this:

What version webdriverio?

Yes, it was related. I had to change hostname from localhost to 127.0.0.1 . (More info: webdriverio/webdriverio#8763)

1 Like