question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cy.visit() failed trying to load ESOCKETTIMEDOUT

See original GitHub issue

Current behavior:

  CypressError: cy.visit() failed trying to load:
 We attempted to make an http request to this URL but the request failed without a response.
 We received this error at the network level:
   > Error: ESOCKETTIMEDOUT
 Common situations why this would fail:
     - you don't have internet access
     - you forgot to run / boot your web server
     - your web server isn't accessible
     - you have weird network configuration settings on your computer
 The stack trace for this error is:
 Error: ESOCKETTIMEDOUT
     at ClientRequest.<anonymous> (/root/.cache/Cypress/4.2.0/Cypress/resources/app/packages/server/node_modules/request/request.js:816:19)
     at Object.onceWrapper (events.js:299:28)
     at ClientRequest.emit (events.js:210:5)
     at TLSSocket.emitRequestTimeout (_http_client.js:690:9)
     at Object.onceWrapper (events.js:299:28)
     at TLSSocket.emit (events.js:210:5)
     at TLSSocket.Socket._onTimeout (net.js:468:8)
     at listOnTimeout (internal/timers.js:531:17)
     at processTimers (internal/timers.js:475:7)
 Because this error occurred during a 'before each' hook we are skipping the remaining tests in the current suite: 'Suite Tests'
image: 'cypress/base'

stages:
  - e2e

end-to-end testing:
  stage: e2e
  script:
    - npm install
    - npm test

Desired behavior:

Does not start testing on gitlab, but on local machine it does works

Test code to reproduce

Starts the tests in gitlab

Versions

Cypress: 4.2.0 Image: cypress/base

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:22
  • Comments:81 (7 by maintainers)

github_iconTop GitHub Comments

13reactions
jon424commented, Dec 11, 2021

Adding this to the cy.visit() function solved it for me:

cy.visit(url, { headers: { "Accept-Encoding": "gzip, deflate" } });

… as referenced here: https://github.com/cypress-io/cypress/issues/943#issuecomment-730705557

12reactions
janhesterscommented, Oct 24, 2021

We were able to solve this issue for our tests with our specific tech stack. We were using Next.js and our Cypress tests ran with the GitHub action.

We changed from:

with:
  start: yarn dev

to

with:
  build: npm run build
  start: npm start
  wait-on: 'http://localhost:3000'

Which caused our tests to run a lot faster and the GitHub action actually waits for the response of the server. We needed BOTH changes because the tests were running on the landing page (which loads fast even in dev mode) before the server was ready, which was fixed by the wait-on. And running the build helped to stay within the timeout window on the slower pages.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cypress, cy.visit() failed trying to load ESOCKETTIMEDOUT
cy.visit('https://github.com/', { timeout: 30000 }). Share. Share a link to this answer ... And in that case I got ESOCKETTIMEDOUT.
Read more >
cypress-io/cypress - Gitter
Can some one pls help. I am trying to open link from cypress. cy.visit("https://www.kohls.com/"). but m getting error :- cy.visit() failed trying to...
Read more >
Cypress tests fail randomly
visit() failed trying to load: cy.visit () failed because you are attempting to visit a different origin domain Two URLs have the same...
Read more >
visit - Cypress Documentation
We recommend setting a baseUrl when using cy.visit() . ... you will need to specify a fully qualified URL or Cypress will attempt...
Read more >
mgr/dashboard: fix ESOCKETTIMEDOUT E2E failure
The dashboard e2e failures are happening for different test suites becasue of a common failure: cy.vist()/cy.request() failed to load ESOCKETTIMEDOUT.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found