webdriverio: @wdio/runner: FetchError: Failed to fetch browser webSocket URL from http://localhost:51804/json/version: request to http://localhost:51804/json/version failed, reason: connect ECONNREFUSED ::1:51804๐Ÿ› Bug]: </h1> <div class="body"><h3>Have you read the Contributing Guidelines on issues?</h3> <ul> <li><input checked disabled type="checkbox"> I have read the <a href="https://github.com/webdriverio/webdriverio/blob/main/CONTRIBUTING.md#reporting-new-issues">Contributing Guidelines on issues</a>.</li> </ul> <h3>WebdriverIO Version</h3> <p>7.16.15</p> <h3>Node.js Version</h3> <p>v17.9.0</p> <h3>Mode</h3> <p>WDIO Testrunner</p> <h3>Which capabilities are you using?</h3> <pre><code class="language-typescript">capabilities: [ { maxInstances: 1, browserName: "Chrome", "goog:chromeOptions": { args: ["--headless"], }, }, ], </code></pre> <h3>What happened?</h3> <p>after starting to work react-native project then I am getting this error while running webdriverio project</p> <p>running API with cucumber</p> <h3>What is your expected behavior?</h3> <p>No error should occur.</p> <h3>How to reproduce the bug.</h3> <p>This is happening randomly.</p> <h3>Relevant log output</h3> <pre><code class="language-typescript"> wdio@1.0.0 test-api > ./node_modules/.bin/wdio run ./config/local/wdio.api.config.js --cucumberOpts.tagExpression "@CartService" Execution of 6 workers started at 2022-04-26T16:27:52.014Z 2022-04-26T16:27:52.025Z INFO @wdio/cli:launcher: Run onPrepare hook 2022-04-26T16:27:52.027Z INFO @wdio/cli:launcher: Run onWorkerStart hook 2022-04-26T16:27:52.028Z INFO @wdio/local-runner: Start worker 0-0 with arg: run,./config/local/wdio.api.config.js,--cucumberOpts.tagExpression,@CartService [0-0] 2022-04-26T16:27:52.424Z INFO @wdio/local-runner: Run worker command: run 2022-04-26T16:27:54.086Z INFO @wdio/cli: [0-0] SKIPPED in Chrome - /test/api/features/login.feature 2022-04-26T16:27:54.086Z INFO @wdio/cli:launcher: Run onWorkerStart hook 2022-04-26T16:27:54.087Z INFO @wdio/local-runner: Start worker 0-1 with arg: run,./config/local/wdio.api.config.js,--cucumberOpts.tagExpression,@CartService [0-1] 2022-04-26T16:27:54.298Z INFO @wdio/local-runner: Run worker command: run [0-1] RUNNING in Chrome - /test/api/features/cart.feature [0-1] 2022-04-26T16:27:55.765Z INFO devtools:puppeteer: Initiate new session using the DevTools protocol [0-1] 2022-04-26T16:27:55.766Z INFO devtools: Launch Google Chrome with flags: --enable-automation --disable-popup-blocking --disable-extensions --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-sync --metrics-recording-only --disable-default-apps --mute-audio --no-first-run --no-default-browser-check --disable-hang-monitor --disable-prompt-on-repost --disable-client-side-phishing-detection --password-store=basic --use-mock-keychain --disable-component-extensions-with-background-pages --disable-breakpad --disable-dev-shm-usage --disable-ipc-flooding-protection --disable-renderer-backgrounding --force-fieldtrials=*BackgroundTracing/default/ --enable-features=NetworkService,NetworkServiceInProcess --disable-features=site-per-process,TranslateUI,BlinkGenPropertyTrees --window-position=0,0 --window-size=1200,900 --headless [0-1] 2022-04-26T16:27:56.799Z INFO devtools: Connect Puppeteer with browser on port 60144 [0-1] 2022-04-26T16:27:56.817Z ERROR @wdio/runner: FetchError: Failed to fetch browser webSocket URL from http://localhost:60144/json/version: request to http://localhost:60144/json/version failed, reason: connect ECONNREFUSED ::1:60144 [0-1] at ClientRequest.<anonymous> (/Users/sayrah/Desktop/decathlonauto/WebDriverIo/dosa-autobot/node_modules/node-fetch/lib/index.js:1491:11) [0-1] at ClientRequest.emit (node:events:527:28) [0-1] at ClientRequest.emit (node:domain:475:12) [0-1] at Socket.socketErrorListener (node:_http_client:454:9) [0-1] at Socket.emit (node:events:527:28) [0-1] at Socket.emit (node:domain:475:12) [0-1] at emitErrorNT (node:internal/streams/destroy:164:8) [0-1] at emitErrorCloseNT (node:internal/streams/destroy:129:3) [0-1] at processTicksAndRejections (node:internal/process/task_queues:83:21) [0-1] FAILED in Chrome - /test/api/features/cart.feature </code></pre> <h3>Code of Conduct</h3> <ul> <li><input checked disabled type="checkbox"> I agree to follow this projectโ€™s Code of Conduct</li> </ul> <h3>Is there an existing issue for this?</h3> <ul> <li><input checked disabled type="checkbox"> I have searched the existing issues</li> </ul> </div> </section> <section class="issueAnalyticsMobile" id="analytics"> <h2>About this issue</h2> <ul> <li><a href="https://github.com/webdriverio/webdriverio/issues/8279" rel="nofollow">Original URL</a></li> <li>State: closed</li> <li>Created 2 years ago</li> <li>Reactions: 5</li> <li>Comments: 29 (7 by maintainers)</li> </ul> </section><section class="issueCommits" id="commits"> <h2>Commits related to this issue</h2> <ul> <li><a href="https://github.com/serenity-js/serenity-js-cucumber-webdriverio-template/commit/53d7b39bfd0152cd55c6e409a54fb5dd6a057a25" rel="nofollow">Run WDIO on Node 14 and 16 as v18 is not fully supported yet - webdriverio/webdriverio#8279</a> <span class="commitMetadata">— committed to <span class="commitRepo"> <a href="https://github.com/serenity-js/serenity-js-cucumber-webdriverio-template" rel="nofollow">serenity-js/serenity-js-cucumber-webdriverio-template</a></span> by <em>jan-molak</em> 2 years ago</span></li><li><a href="https://github.com/alphagov/govuk-frontend/commit/90791a088da2bfa24efb3a89277069fb73ced930" rel="nofollow">Fix watch mode erroring after change and stopping tests https://github.com/webdriverio/webdriverio/issues/8279\#issuecomment-1295996734 An error (different from before) gets logged in the console, b...</a> <span class="commitMetadata">— committed to <span class="commitRepo"> <a href="https://github.com/alphagov/govuk-frontend" rel="nofollow">alphagov/govuk-frontend</a></span> by <em>romaricpascal</em> a year ago</span></li><li><a href="https://github.com/alphagov/govuk-frontend/commit/2689c5b606d1284d30e05333717dcf797a1f6368" rel="nofollow">Fix watch mode erroring after change and stopping tests https://github.com/webdriverio/webdriverio/issues/8279\#issuecomment-1295996734 An error (different from before) gets logged in the console, b...</a> <span class="commitMetadata">— committed to <span class="commitRepo"> <a href="https://github.com/alphagov/govuk-frontend" rel="nofollow">alphagov/govuk-frontend</a></span> by <em>romaricpascal</em> a year ago</span></li><li><a href="https://github.com/serenity-js/serenity-js/commit/77b423eefead639214af782fae831488e1380eda" rel="nofollow">ci(github): run WebdriverIO tests on Node 16 as WebdriverIO v7 doesn't support Node 18 Related tickets: webdriverio/webdriverio#8279</a> <span class="commitMetadata">— committed to <span class="commitRepo"> <a href="https://github.com/serenity-js/serenity-js" rel="nofollow">serenity-js/serenity-js</a></span> by <em>jan-molak</em> a year ago</span></li><li><a href="https://github.com/serenity-js/serenity-js/commit/b690e3c963e9c8a85a9d15df9837f1df78faff1a" rel="nofollow">ci(github): run WebdriverIO tests on Node 16 as WebdriverIO v7 doesn't support Node 18 Related tickets: webdriverio/webdriverio#8279</a> <span class="commitMetadata">— committed to <span class="commitRepo"> <a href="https://github.com/serenity-js/serenity-js" rel="nofollow">serenity-js/serenity-js</a></span> by <em>jan-molak</em> a year ago</span></li> </ul> </section><section class="issueComments" id="topComments"> <h2>Most upvoted comments</h2> <div class="comments"> <div class="comment" key="0"> <div class="commentBody"><p>The following config hook fixed it for me:</p> <pre><code class="language-js"> beforeSession: () => { dns.setDefaultResultOrder('ipv4first'); }, </code></pre> </div> <div class="commentMetadata"> <div class="reactions"> <span>+7</span> </div> <div class="attribution"> <a href="https://github.com/bjouhier" rel="nofollow">bjouhier</a> on <a href="https://github.com/webdriverio/webdriverio/issues/8279#issuecomment-1295996734" rel="nofollow">Oct 29, 2022</a> </div> </div> </div><div class="comment" key="1"> <div class="commentBody"><blockquote> <p>The following config hook fixed it for me:</p> <pre><code class="language-js"> beforeSession: () => { dns.setDefaultResultOrder('ipv4first'); }, </code></pre> </blockquote> <p>Hi all. We had the same issue since working with node v18.12.1 and the mentioned beforeSession hook fixed the problem in our case. Upgrading to Webdriver v8 seems to require a big refactoring for us because of the switch do ES Module.</p> </div> <div class="commentMetadata"> <div class="reactions"> <span>+4</span> </div> <div class="attribution"> <a href="https://github.com/thorsten-wolf-neptune" rel="nofollow">thorsten-wolf-neptune</a> on <a href="https://github.com/webdriverio/webdriverio/issues/8279#issuecomment-1376921417" rel="nofollow">Jan 10, 2023</a> </div> </div> </div><div class="comment" key="2"> <div class="commentBody"><blockquote> <p>The following config hook fixed it for me:</p> <pre><code class="language-js"> beforeSession: () => { dns.setDefaultResultOrder('ipv4first'); }, </code></pre> </blockquote> <p>Worked for me. node 19.2.0 macOS 12.6</p> </div> <div class="commentMetadata"> <div class="reactions"> <span>+3</span> </div> <div class="attribution"> <a href="https://github.com/AndyLysenko" rel="nofollow">AndyLysenko</a> on <a href="https://github.com/webdriverio/webdriverio/issues/8279#issuecomment-1340708760" rel="nofollow">Dec 7, 2022</a> </div> </div> </div><div class="comment" key="3"> <div class="commentBody"><p>I had the same issue after upgrade to node 18.18.0 (the current LTS) The issue seems to be solved after iโ€™ve upgraded to the latest wdio versions - 8.16.15 Fingers crossed!</p> </div> <div class="commentMetadata"> <div class="reactions"> <span>+2</span> </div> <div class="attribution"> <a href="https://github.com/alek75" rel="nofollow">alek75</a> on <a href="https://github.com/webdriverio/webdriverio/issues/8279#issuecomment-1737148617" rel="nofollow">Sep 27, 2023</a> </div> </div> </div><div class="comment" key="4"> <div class="commentBody"><blockquote> <p>Upgrading to Webdriver v8 seems to require a big refactoring for us because of the switch do ES Module.</p> </blockquote> <p>You can use WebdriverIO v8 within CJS projects as well.</p> </div> <div class="commentMetadata"> <div class="reactions"> <span>+1</span> </div> <div class="attribution"> <a href="https://github.com/christian-bromann" rel="nofollow">christian-bromann</a> on <a href="https://github.com/webdriverio/webdriverio/issues/8279#issuecomment-1378383514" rel="nofollow">Jan 11, 2023</a> </div> </div> </div><div class="comment" key="5"> <div class="commentBody"><blockquote> <p>What is <code>dns</code>?</p> </blockquote> <p>It is a <a href="https://nodejs.org/api/dns.html">Node.js</a> module, e.g.</p> <pre><code class="language-ts">import dns from 'node:dns' </code></pre> </div> <div class="commentMetadata"> <div class="reactions"> <span>+1</span> </div> <div class="attribution"> <a href="https://github.com/christian-bromann" rel="nofollow">christian-bromann</a> on <a href="https://github.com/webdriverio/webdriverio/issues/8279#issuecomment-1309073859" rel="nofollow">Nov 9, 2022</a> </div> </div> </div><div class="comment" key="6"> <div class="commentBody"><p>This also occurred for me on my local machine in node 18.3.0. I ran an npm update and the issue went away locally.</p> <p>After pushing my code to our bitbucket pipelines itโ€™s occurring once again. I also tried on node v17, and had the same result (see below)</p> <pre><code>2022-08-18T01:46:30.494Z DEBUG @wdio/local-runner:utils: init remote session 2022-08-18T01:46:30.509Z INFO devtools:puppeteer: Initiate new session using the DevTools protocol 2022-08-18T01:46:30.510Z INFO devtools: Launch Google Chrome with flags: --enable-automation --disable-popup-blocking --disable-extensions --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-sync --metrics-recording-only --disable-default-apps --mute-audio --no-first-run --no-default-browser-check --disable-hang-monitor --disable-prompt-on-repost --disable-client-side-phishing-detection --password-store=basic --use-mock-keychain --disable-component-extensions-with-background-pages --disable-breakpad --disable-dev-shm-usage --disable-ipc-flooding-protection --disable-renderer-backgrounding --force-fieldtrials=*BackgroundTracing/default/ --enable-features=NetworkService,NetworkServiceInProcess --disable-features=site-per-process,TranslateUI,BlinkGenPropertyTrees --window-position=0,0 --window-size=1200,900 --headless --no-sandbox 2022-08-18T01:46:31.093Z INFO devtools: Connect Puppeteer with browser on port 37453 2022-08-18T01:46:31.114Z ERROR @wdio/runner: FetchError: Failed to fetch browser webSocket URL from [http://localhost:37453/json/version:](http://localhost:37453/json/version) request to http://localhost:37453/json/version failed, reason: connect ECONNREFUSED ::1:37453 at ClientRequest.<anonymous> (/opt/atlassian/pipelines/agent/build/node_modules/node-fetch/lib/index.js:1491:11) at ClientRequest.emit (node:events:527:28) at ClientRequest.emit (node:domain:475:12) at Socket.socketErrorListener (node:_http_client:454:9) at Socket.emit (node:events:527:28) at Socket.emit (node:domain:475:12) at emitErrorNT (node:internal/streams/destroy:164:8) at emitErrorCloseNT (node:internal/streams/destroy:129:3) at processTicksAndRejections (node:internal/process/task_queues:83:21) </code></pre> <p>My current work around was to downgrade to 16.17.0.</p> </div> <div class="commentMetadata"> <div class="reactions"> <span>+1</span> </div> <div class="attribution"> <a href="https://github.com/posthello-code" rel="nofollow">posthello-code</a> on <a href="https://github.com/webdriverio/webdriverio/issues/8279#issuecomment-1218931499" rel="nofollow">Aug 18, 2022</a> </div> </div> </div> </div> <div class="moreComments"> <a href="https://github.com/webdriverio/webdriverio/issues/8279" rel="nofollow">Read more comments on GitHub</a> </div> </section><section class="issueNavigation"> <div class="back"> <a href="https://errorism.dev/issues/webdriverio-webdriverio-wdiomocha-framework6106-introduces-typescript-errors"> ← webdriverio: @wdio/mocha-framework@6.10.6 introduces TypeScript errors </a> </div> <div class="forward"> <a href="https://errorism.dev/issues/webdriverio-webdriverio-wdiosync-httperror-response-code-404-not-found"> webdriverio: @wdio/sync: HTTPError: Response code 404 (Not Found) → </a> </div> </section> </div> <aside class="sidebar"> <div class="tocWrapper"> <span class="tocTitle">Table of contents</span> <a class="tocItem" href="#issueDescription">Issue description</a> <a class="tocItem" href="#commits">Related commits</a> <a class="tocItem" href="#topComments">Top comments</a> </div> <div class="analyticsWrapper"> <span class="analyticsTitle">About this issue</span> <a class="analyticsItem" href="https://github.com/webdriverio/webdriverio/issues/8279" rel="nofollow">Original URL</a> <span class="analyticsItem">State: closed</span> <span class="analyticsItem">Created 2 years ago</span> <span class="analyticsItem">Reactions: 5</span> <span class="analyticsItem">Comments: 29 (7 by maintainers)</span> </div> </aside> </div> </main> <!--<footer class="footerContainer">--> <!-- <div class="footerContent">--> <!-- <div class="footerLinks">--> <!-- <a class="footerLink" href="/about">About Errorism</a>--> <!-- <a class="footerLink" href="/privacy-policy">Privacy Policy</a>--> <!-- <a class="footerLink" href="/contact">Contact</a>--> <!-- </div>--> <!-- </div>--> <!--</footer>--> </div> </body></html>