'I am getting "ERROR webdriver: Request failed with status undefined due to TimeoutError:" while executing the runner command

I tried to upgrade my webdriverIO framework to the latest version.
Old Setup: 
WebdriverIO - V6
NodeJS (version: 12.16.0 ) and NPM (version: 6.5.0)

New setup: 
WebdriverIO - v7NodJS (version: 14.15.1 ) and NPM (version: 8.9.0)

"devDependencies": { "@types/chai": "^4.3.1", "@types/cucumber": "^6.0.1", "@types/lodash": "^4.14.182", "@types/node": "^17.0.31", "@typescript-eslint/eslint-plugin": "^5.22.0", "@typescript-eslint/parser": "^5.22.0", "cucumber": "^6.0.7", "eslint": "^8.14.0", "eslint-config-airbnb": "^19.0.4", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-prettier": "^8.5.0", "eslint-plugin-import": "^2.26.0", "eslint-plugin-prettier": "^4.0.0", "typescript": "4.6.4" },

"dependencies": { "@cucumber/cucumber": "^8.2.0", "@wdio/allure-reporter": "^7.19.7", "@wdio/cli": "^7.19.7", "@wdio/codemod": "^0.12.0", "@wdio/cucumber-framework": "^7.19.7", "@wdio/dot-reporter": "^7.19.7", "@wdio/firefox-profile-service": "^7.19.5", "@wdio/junit-reporter": "^7.19.7", "@wdio/local-runner": "^7.19.7", "@wdio/sauce-service": "7.19.7", "@wdio/selenium-standalone-service": "7.19.5", "@wdio/spec-reporter": "^7.19.7", "allure-commandline": "^2.17.2", "chai": "^4.3.6", "cheerio": "^1.0.0-rc.10", "chromedriver": "101.0.0", "cucumber-html-reporter": "^5.5.0", "cucumber-pretty": "^6.0.1", "cucumber-tsflow": "^3.4.1", "fs-extra": "^10.1.0", "geckodriver": "^3.0.1", "iedriver": "^4.0.0", "jscodeshift": "^0.13.1", "lodash": "^4.17.21", "mail-listener6": "^2.0.3", "mailparser": "^3.5.0", "module-alias": "^2.2.2", "moment": "^2.29.3", "multiple-cucumber-html-reporter": "^1.20.0", "query-selector-shadow-dom": "^1.0.0", "wdio-cucumberjs-json-reporter": "4.4.1", "wdio-iedriver-service": "^0.1.0", "webdriverio": "7.19.7" },

I have upgraded my framework with latest packages as required.
But I am getting below error while executing the script:


Execution of 1 workers started at 2022-05-09T09:06:40.611Z

Failed to connect to selenium. Attempts left: 115 
 connect ECONNREFUSED 127.0.0.1:4444
[0-0] [
[0-0]   {
[0-0]     maxInstances: 4,
[0-0]     browserName: 'chrome',
[0-0]     browserVersion: 'latest',
[0-0]     platformName: 'Windows',
[0-0]     'goog:chromeOptions': { prefs: [Object], localState: [Object], args: [Array] }
[0-0]   }
[0-0] ]
ERROR webdriver: Request failed with status undefined due to TimeoutError: Timeout awaiting 'request' for 60000ms when running "http://localhost:4444/wd/hub/session" with method 
"POST" and args "{"capabilities":{"alwaysMatch":{"browserName":"chrome","browserVersion":"latest","platformName":"Windows","goog:chromeOptions":{"prefs":{"download":{"default_directory":"xyzpath\\downloads","directory_upgrade":true,"prompt_for_download":false},"credentials_enable_service":false},"localState":{"browser.enabled_labs_experiments":["calculate-native-win-occlusion@2"]},"args":["--window-size=1366,768","--test-type=browser","disable-infobars=true"]}},"firstMatch":[{}]},"desiredCapabilities":{"browserName":"chrome","browserVersion":"latest","platformName":"Windows","goog:chromeOptions":{"prefs":{"download":{"default_directory":"xyzpath\\downloads","directory_upgrade":true,"prompt_for_download":false},"credentials_enable_service":false},"localState":{"browser.enabled_labs_experiments":["calculate-native-win-occlusion@2"]},"args":["--window-size=1366,768","--test-type=browser","disable-infobars=true"]}}}"
[0-0] 2022-05-09T09:10:52.787Z ERROR webdriver: TimeoutError: Timeout awaiting 'request' for 60000ms when running "http://localhost:4444/wd/hub/session" with method "POST" and args "{"capabilities":{"alwaysMatch":{"browserName":"chrome","browserVersion":"latest","platformName":"Windows","goog:chromeOptions":{"prefs":{"download":{"default_directory":"xyzpath\\downloads","directory_upgrade":true,"prompt_for_download":false},"credentials_enable_service":false},"localState":{"browser.enabled_labs_experiments":["calculate-native-win-occlusion@2"]},"args":["--window-size=1366,768","--test-type=browser","disable-infobars=true"]}},"firstMatch":[{}]},"desiredCapabilities":{"browserName":"chrome","browserVersion":"latest","platformName":"Windows","goog:chromeOptions":{"prefs":{"download":{"default_directory":"xyzpath\\downloads","directory_upgrade":true,"prompt_for_download":false},"credentials_enable_service":false},"localState":{"browser.enabled_labs_experiments":["calculate-native-win-occlusion@2"]},"args":["--window-size=1366,768","--test-type=browser","disable-infobars=true"]}}}"

Error in below files:

[0-0]     at getTimeoutError (xyzpath\node_modules\webdriver\build\utils.js:320:24)
[0-0]     at NodeJSRequest._request (xyzpath\node_modules\webdriver\build\request\index.js:154:59)
[0-0]     at processTicksAndRejections (internal/process/task_queues.js:93:5)
[0-0]     at startWebDriverSession (xyzpath\node_modules\webdriver\build\utils.js:67:20)
[0-0]     at Function.newSession (xyzpath\node_modules\webdriver\build\index.js:46:45)
[0-0]     at remote (xyzpath\node_modules\webdriverIO\build\index.js:77:22)
[0-0]     at Runner._startSession (xyzpath\node_modules\@wdio\runner\build\index.js:223:56)
[0-0]     at Runner._initSession (xyzpath\node_modules\@wdio\runner\build\index.js:176:25)
[0-0]     at Runner.run (xyzpath\node_modules\@wdio\runner\build\index.js:88:19)

Let me know any more information is required incase of upgrading the framework.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source