Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.7.0 - Cypress failed to make a connection to the Chrome DevTools Protocol #5912

Closed
adrians5j opened this issue Dec 7, 2019 · 30 comments · Fixed by #5960 · May be fixed by qsays/grafana#1
Closed

3.7.0 - Cypress failed to make a connection to the Chrome DevTools Protocol #5912

adrians5j opened this issue Dec 7, 2019 · 30 comments · Fixed by #5960 · May be fixed by qsays/grafana#1

Comments

@adrians5j
Copy link

adrians5j commented Dec 7, 2019

Current behavior:

Basically, I'm having the same issue mentioned in the #5431. I installed cypress via yarn add --dev cypress, and just wanted to run tests that were initially provided.

image

Logs (an excerpt) received after running DEBUG=* cypress open

  cypress:network:connect received error on connect, retrying { iteration: 30, delay: 1000, err: { Error: connect ECONNREFUSED ::1:50516 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1061:14) errno: 'ECONNREFUSED', code: 'ECONNREFUSED', syscall: 'connect', address: '::1', port: 50516 } } +1s
Failed to connect to Chrome, retrying in 1 second (attempt 31/32)
  cypress:network:connect received error on connect, retrying { iteration: 31, delay: 1000, err: { Error: connect ECONNREFUSED ::1:50516 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1061:14) errno: 'ECONNREFUSED', code: 'ECONNREFUSED', syscall: 'connect', address: '::1', port: 50516 } } +1s
Failed to connect to Chrome, retrying in 1 second (attempt 32/32)
  cypress:network:connect received error on connect, retrying { iteration: 32, delay: 1000, err: { Error: connect ECONNREFUSED ::1:50516 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1061:14) errno: 'ECONNREFUSED', code: 'ECONNREFUSED', syscall: 'connect', address: '::1', port: 50516 } } +1s
  cypress:network:connect retries exhausted, bubbling up error { iteration: 33, err: { Error: connect ECONNREFUSED ::1:50516 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1061:14) errno: 'ECONNREFUSED', code: 'ECONNREFUSED', syscall: 'connect', address: '::1', port: 50516 } } +1s
  cypress:server:protocol failed to connect to CDP { port: 50516, err: { Error: Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 20 seconds. This usually indicates there was a problem opening the Chrome browser. The CDP port requested was 50516. Error details: Error: connect ECONNREFUSED ::1:50516 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1061:14) at get (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/lib/errors.js:319:11) at Object.throwErr [as throw] (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/lib/errors.js:334:11) at /Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/protocol.js:38:17 at tryCatcher (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:725:18) at _drainQueueStep (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (internal/timers.js:443:21) isCypressErr: true, type: 'CDP_COULD_NOT_CONNECT', details: undefined } } +20s
  cypress:server:events send error: { Error: Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 20 seconds. This usually indicates there was a problem opening the Chrome browser. The CDP port requested was 50516. Error details: Error: connect ECONNREFUSED ::1:50516 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1061:14) at get (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/lib/errors.js:319:11) at Object.throwErr [as throw] (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/lib/errors.js:334:11) at /Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/protocol.js:38:17 at tryCatcher (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:725:18) at _drainQueueStep (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (internal/timers.js:443:21) isCypressErr: true, type: 'CDP_COULD_NOT_CONNECT', details: undefined } +9s
  cypress:server:events sending ipc data { type: 'launch:browser', data: { id: 0.05457888759571827, __error: { type: 'CDP_COULD_NOT_CONNECT', name: 'Error', stack: 'Error: Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 20 seconds.\n\nThis usually indicates there was a problem opening the Chrome browser.\n\nThe CDP port requested was \u001b[33m50516\u001b[39m.\n\nError details:\n\nError: connect ECONNREFUSED ::1:50516\n    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1061:14)\n\n    at get (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/lib/errors.js:319:11)\n    at Object.throwErr [as throw] (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/lib/errors.js:334:11)\n    at /Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/lib/browsers/protocol.js:38:17\n    at tryCatcher (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)\n    at Promise._settlePromiseFromHandler (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:547:31)\n    at Promise._settlePromise (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:604:18)\n    at Promise._settlePromise0 (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:649:10)\n    at Promise._settlePromises (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/promise.js:725:18)\n    at _drainQueueStep (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:93:12)\n    at _drainQueue (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:86:9)\n    at Async._drainQueues (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:102:5)\n    at Immediate.Async.drainQueues [as _onImmediate] (/Users/adrian/Library/Caches/Cypress/3.7.0/Cypress.app/Contents/Resources/app/packages/server/node_modules/bluebird/js/release/async.js:15:14)\n    at processImmediate (internal/timers.js:443:21)\n', message: 'Cypress failed to make a connection to the Chrome DevTools Protocol after retrying for 20 seconds.\n\nThis usually indicates there was a problem opening the Chrome browser.\n\nThe CDP port requested was <span class="ansi-yellow-fg">50516</span>.\n\nError details:\n\nError: connect ECONNREFUSED ::1:50516\n    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1061:14)\n', isCypressErr: true, details: undefined } } } +2ms
  cypress:server:events got request for event: get:project:status, { path: '/Users/adrian/dev/wby/examples' } +740ms
  cypress:server:project get project status for client id undefined at path /Users/adrian/dev/wby/examples +10s
  cypress:server:project no project id +0ms
  cypress:server:events sending ipc data { type: 'get:project:status', data: { id: 0.8992179444644883, data: { path: '/Users/adrian/dev/wby/examples', state: 'VALID' } } } +1ms
  cypress:server:events got request for event: get:project:status, { path: '/Users/adrian/dev/wby/examples' } +10s
  cypress:server:project get project status for client id undefined at path /Users/adrian/dev/wby/examples +10s
  cypress:server:project no project id 

Desired behavior:

Be able to run tests.

Versions

Cypress 3.7.0
Mac OS Mojave, 10.14.4
Node v8.16.2
Yarn v1.15.2

Sorry if I missed some of the details, please let me know if I did.

Thanks for making this awesome piece of software :)

P.S. When I run cypress run, which should I guess run tests via Electron, I can also see the ECONNREFUSED issues.

@ray1618
Copy link

ray1618 commented Dec 11, 2019

I have the same issue as above, chrome, chromium & canary all trow this error. Electron is the only option that is working for me at the moment.

Versions:
Cypress 3.7.0
Windows 10
node 10.16.3
npm 6.13.0

@adrians5j
Copy link
Author

adrians5j commented Dec 12, 2019

Weirdly enough, I asked my colleague to try to run the same thing on his Mac (the same Mac OS Mojave, 10.14.4), everything worked as expected. Still can't find what's causing the issue for me :/

@adrians5j
Copy link
Author

adrians5j commented Dec 12, 2019

BTW I installed the Chromium, and selected it via the Cypress UI. The same error happens. I just wanted to check if it's something related to Chrome or not.

@ray1618
Copy link

ray1618 commented Dec 12, 2019

I installed the project at home at another windows pc and it runs flawless.

Tried at the office on multiple chromium, chrome and canary versions and it doesn’t work. Firewall is turned off, chrome has no user policies applied and proxies turned off.

@adrians5j
Copy link
Author

It looks like there's nothing else to do, but to start reading about Chrome DevTools Protocol. I'll try to see why a connection couldn't be established to it, but over the weekend. Kinda buried in work at the moment, trying to ship things :/

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Dec 13, 2019
@jennifer-shehane
Copy link
Member

Are any of you also able to pin this down to a specific Cypress version? Like "it works in 3.4.1, but fails starting in 3.5"?

@adrians5j adrians5j reopened this Dec 13, 2019
@adrians5j
Copy link
Author

adrians5j commented Dec 13, 2019

Tried 3.5, 3.7, and 3.8.

Now also installed the 3.4.1, and got the same issue.

At this point, I believe there has to be something incorrectly configured on my Mac / Chrome. I don't think it's related to the Cypress itself, at least it doesn't look like it.

Cypress 3.4.1:
image

This was tested with Chrome 79 and Chromium 61.
@jennifer-shehane

@ray1618
Copy link

ray1618 commented Dec 13, 2019

Also had this on multiple versions, 3.5 and 3.7 on Windows 10

@flotwig
Copy link
Contributor

flotwig commented Dec 13, 2019

@doitadrian Do you see anything in chrome://policy if you open that URL in Chrome?

You might also want to try launching Cypress with all other Chrome windows closed.

If you can provide the full DEBUG logs, we can see what Chrome is launching with, maybe it is getting passed an incorrect --remote-debugging-port or something.

@adrians5j
Copy link
Author

adrians5j commented Dec 13, 2019

Thanks @flotwig for the response.

Checked the chrome://policy, nothing interesting there:
image

Tried closing all other Chrome windows, the same issue happens again.

I can provide the full DEBUG logs, just not sure what would be the best way to get it. The following shows logs printed in the terminal, using DEBUG=* cypress open, and then running a single test:

image

Should I c/p everything to you?

@ray1618
Copy link

ray1618 commented Dec 13, 2019

Seems policies are not the problem, but for me policies:
developertoolsavailability : 1 (allow usage of developer tools)
Restore on startup: 4
Restore on startup urls : our intranet

@flotwig
Copy link
Contributor

flotwig commented Dec 13, 2019

@doitadrian It looks like Cypress is unable to spawn its own instance - you should not be seeing your browser extensions "AdBlock" and "Grammarly" inside of Cypress. This generally only happens because of some device management policy that sees the behavior of Cypress as malicious. Is your computer managed?

A good workaround is to try running with the Chromium browser instead of Chrome. That may circumvent these restrictions. The built-in Electron should work as well.

@ray1618 Same here - it's likely that there are other policies interfering with the correct launching of Chrome. Try Chromium, or the built-in Electron.

@adrians5j
Copy link
Author

adrians5j commented Dec 13, 2019

Thank you for the response @flotwig!

I'm sorry, I actually sent you the policies view from a regular Chrome that I use, not from the one that Cypress spawns. When I open the same thing now in that Cypress spawned Chrome, I get the following:

image

My computer isn't managed.

I tried running tests in Chromium and Electron, for both I get the same exact error, for example Electron:

image

BTW, here is the entire c/p log of DEBUG=cypress:* cypress run --browser electron:

cy-logs.txt

@flotwig
Copy link
Contributor

flotwig commented Dec 13, 2019

Hmmm... I wonder if localhost is resolving to ::1 instead of 127.0.0.1 for some reason. Maybe try temporarily removing ::1 localhost from /etc/hosts and re-running Cypress?

@adrians5j
Copy link
Author

Let me see...

@adrians5j
Copy link
Author

👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍 👍

@adrians5j
Copy link
Author

Can't believe it, it works! 🎉🎉🎉🎉🎉

@adrians5j
Copy link
Author

adrians5j commented Dec 13, 2019

So yeah, I just commented out the following line in the `/etc/hosts/ file, and the thing worked:

::1             localhost

Woa @flotwig, thanks a lot, not sure why this was happening nor why was this entry in my hosts file.

🍻🍻🍻

@flotwig
Copy link
Contributor

flotwig commented Dec 13, 2019

🍺 Glad you got it figured out. We try to stick to using 127.0.0.1 in the test runner, never localhost, for exactly this reason. This should probably get tracked down and changed to use 127.0.0.1 explicitly.

@bahmutov
Copy link
Contributor

bahmutov commented Dec 13, 2019 via email

@flotwig
Copy link
Contributor

flotwig commented Dec 13, 2019

@bahmutov this error will happen anywhere we use localhost, so the error would apply to all network requests

@adrians5j
Copy link
Author

adrians5j commented Dec 13, 2019

On my end, the only thing I received was:
image

And of course, the ECONNREFUSED errors in the console, which wasn't very helpful, hence this issue. Now that we've found the solution, I can see the ::1 in the Cypress error message, but as a regular user, that unfortuntately didn't indicate to me that there might be a problem.

Hope this helps..

@adrians5j
Copy link
Author

As far as I'm concerned, we can close this issue, Not sure about @ray1618 though.

Thanks again for the help guys, now let's write some tests 😊

@bahmutov
Copy link
Contributor

bahmutov commented Dec 13, 2019 via email

@ray1618
Copy link

ray1618 commented Dec 13, 2019

@doitadrian I'll try editing the hosts file tomorrow

@cypress-bot cypress-bot bot removed the stage: needs information Not enough info to reproduce the issue label Dec 13, 2019
@ray1618
Copy link

ray1618 commented Dec 14, 2019

Checked my hostfile, no redirects in here from ::1 my error looks the same as the screenshot of doitardrian

image

And of course, the ECONNREFUSED errors in the console, which wasn't very helpful, hence this issue. Now that we've found the solution, I can see the ::1 in the Cypress error message, but as a regular user, that unfortuntately didn't indicate to me that there might be a problem.

Hope this helps..

Only differnce that instead of ::1 it references to 127.0.0.1
Error: connect ECONNREFUSED 127.0.0.1:53111 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1061:14)

@flotwig
Copy link
Contributor

flotwig commented Dec 16, 2019

@ray1618 This seems like a different issue than Adrian's. I know you mentioned that you have no Chrome policy set, but can you do me a favor? Double-check that, in the browser opened by Cypress, the URL chrome://policy is blank and contains only one section.

If it is indeed blank, management is probably not the issue. You can try running your tests with debug logs enabled, and share those logs here. It will show some more information which we can use to get to the root of the issue.

  • On Linux/macOS: DEBUG=cypress:* cypress ...
  • On Windows: npx cross-env DEBUG=cypress:* cypress ...

Make sure to scrub any private data from the logs before sharing here.

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Dec 17, 2019
@jennifer-shehane
Copy link
Member

Hey @ray1618, any followup on the debug steps mentioned by Zach above? #5912 (comment)

@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Dec 19, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 19, 2019

The code for this is done in cypress-io/cypress#5960, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 26, 2019

Released in 3.8.1.

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Dec 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants