cypress "The browser never connected" - Chrome crashing under CI memory pressure: how to fix
Fixes Cypress's 'The browser never connected' error caused by Chrome crashing under CI memory pressure. Shows how to pass --disable-dev-shm-usage to Chrome, reduce parallel browser workers, and verify the container's memory before rerunning. Use when Cypress cannot launch or keep Chrome alive in CI while local runs work. Not for browser version mismatches, GPU crashes, or tests that launch but then fail.
TL;DR
Chrome crashes in small CI containers because the shared-memory partition it renders into is tiny, and under memory pressure the whole browser dies before Cypress can connect. Pass --disable-dev-shm-usage in the browser launch args so Chrome uses disk-backed temp space instead, cut the number of parallel browser workers, and the browser stays alive long enough to run your suite.
cypress "The browser never connected" - Chrome crashing under CI memory pressure: how to fixSteps
- Check the CI job's memory limit and how many Cypress browser workers run at once. Compare with the size of
/dev/shminside the container. Expected: you confirm the container is memory-tight (small shm, several workers). - Add the launch flag in your Cypress config so Chrome avoids the tiny shared-memory partition:
setupNodeEvents(on, config) {
on('before:browser:launch', function(browser, launchOptions) {
if (browser.name === 'chrome') {
launchOptions.args.push('--disable-dev-shm-usage')
}
return launchOptions
})
}Expected: the config loads and the flag is present in the launch args.
- Reduce parallel workers (fewer
--parallelmachines or a lower per-machine thread count) so each browser gets more headroom. Expected: peak memory per worker drops. - Rerun the suite in CI. Expected: Chrome launches, stays alive, and tests start instead of the "never connected" error.
Use this when
- Cypress reports "The browser never connected" only in CI
- The CI container has limited memory or a small /dev/shm
- Chrome works locally but dies immediately in the pipeline
Not for this skill when
- The browser launches but tests fail (that is a test problem, not a launch problem)
- The error names a GPU process crash (see the GPU-crash skill instead)
- The browser binary is missing or the version is wrong (install or pin the browser first)
Variant phrasings
- cypress browser never connected in CI
- chrome crashing in cypress CI container
- cypress chrome died under memory pressure
Why it happens
Chrome uses /dev/shm for rendering buffers, and Docker-style CI containers default that partition to 64MB. Under parallel test load Chrome exhausts it and the renderer crashes, taking the browser down before Cypress ever connects. Local machines have gigabytes of shared memory, which is why the bug is CI-only.
Edge cases
- If crashes persist, raise the container memory limit or the shm size in the CI runner config; the flag is a workaround, not infinite headroom.
- Firefox has its own memory behavior and does not take the same flag; this fix is Chrome-specific.
- A crash that happens mid-suite rather than at launch points at a leaking page, not shm size. Watch memory across a single long spec to tell the two apart.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_VMz7VIXXSgVcbCyxxzT6vw