cypress: ESOCKETTIMEDOUT error
The issue is occurring on my colleague’s machine who is offshore (India time). I am submitting this issue on his behalf. Due to the time discrepancy, responses may be slow. However this is a blocking issue for our team since we are trying to convert to using Cypress and TDD as a team thus we need the environment to be working on all machines before beginning our new work. I’ve googled this issue and tried diagnosing/solving it but so far no luck.
Additional Info (images, stack traces, etc)
Console was cleared
cypress_runner.js:136628 Command: visit
cypress_runner.js:136628 Error: CypressError: cy.visit() failed trying to load:
http://localhost:9000/
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> (C:\Data\Testing\cypress\Cypress\resources\app\packages\server\node_modules\request\request.js:778:19)
at ClientRequest.g (events.js:286:16)
at emitNone (events.js:86:13)
at ClientRequest.emit (events.js:185:7)
at Socket.emitTimeout (_http_client.js:614:10)
at Socket.g (events.js:286:16)
at emitNone (events.js:86:13)
at Socket.emit (events.js:185:7)
at Socket._onTimeout (net.js:334:8)
at tryOnTimeout (timers.js:232:11)
at Timer.listOnTimeout (timers.js:202:5)
Because this error occurred during a 'before each' hook we are skipping the remaining tests in the current suite: 'Enter BAC Details Wizard Forms'
cypress_runner.js:136628 Snapshot: The snapshot is missing. Displaying current state of the DOM.

- Operating System: Windows 7
- Cypress Version: 1.0.3
- Browser Version: 62
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 29 (6 by maintainers)
Commits related to this issue
- Add header to avoid timeout error Per this comment on a GitHub issue: https://github.com/cypress-io/cypress/issues/943#issuecomment-523349234 Worth a try. — committed to tipresias/tipresias by cfranklin11 5 years ago
- Add headers to Cypress homepage test Attempt to fix the Cypress homepage test which is failing due to: ```error 1) Homepage HomeHeader "before all" hook for "should exist": Cyp... — committed to rootulp/index-ui by rootulp 3 years ago
- Test cypress with accpeted encoding (from github issue: https://github.com/cypress-io/cypress/issues/943) — committed to holgergp/soccerJotai by holgergp 2 years ago
For me I had a webserver which failed if it could not find the “Accept-Encoding” header.
Fixed with :
We’ve fixed the problem by adding a request header (
Connection: "Keep-Alive") to the visit command.This also happens to me when testing inside our CI environment(codeship basic). There is no problem with local environment, but on CI,
ESOCKETTIMEDOUToccurs about half of the time, when visiting an url usingcy.visit().Is this a problem of our CI server(i.e., too slow)? Or, just changing timeout configuration is enough?
(UPDATE) I doubled
pageLoadTimeoutonly on CI and it works as expected. But I’m still not sure this is the right solution to the problem.Thank you, @thomasleveil ! This was driving me crazy and your suggestion worked like a charm.
Today, I’m seeing this error while running Charles Proxy to forward our prod domain to localhost:9002. For me it happens consistently on the same test during the login process… but if I run a single spec instead of all tests, it happens in a different place (after a certain number of requests have been made maybe)?
Perhaps it is some inconsistency with the proxy in different environments?
If I run it against our prod environment without going through Charles Proxy, there are no issues whatsoever.
I made some progress by bumping up the
UV_THREADPOOL_SIZEbut not much. I addedprocess.env.UV_THREADPOOL_SIZE = 64;to the beginning ofcypress/support/index.jswhich consistently allows more tests to run before connections stop working and Cypress ultimately crashes.Once the timeouts start, it doesn’t matter if I stop and restart a spec. As long as the same node process (that started Cypress) is still running, all connections fail.
node v12.8.1 cypress v3.4.1
I spoke too soon. This worked for me locally, but when I ran the same test in a CodeBuild job, I got the ESOCKETTIMEDOUT error again, despite having
"Accept-Encoding": "gzip, deflate"in the headers.I’m getting a similar issue running this locally against a dockerized django app. My cypress service is linked to the app.
I get the following errors:
It’s not consistently reproducible but I also encounter this issue as well, on several specs.