# Angular tests: Disconnected, because no message in 30000 ms. / ERROR [launcher]: Cannot start ChromeHeadless

**Code:** `Karma Disconnected / no captured browser` · **Category:** Angular · **Seen on:** Angular, Angular CLI, Linux

`ng test` could not start or keep the browser Karma uses — Chrome is missing, runs as root in a container, or the test run hung.

## Meaning

In CI and Docker Chrome must start without a sandbox (`--no-sandbox`) or as a non-root user. "Disconnected, because no message in 30000 ms" usually means a test blocked the browser (infinite loop, unresolved promise without `fakeAsync`), or the machine is too slow. "Cannot start ChromeHeadless" means Chrome is not installed or `CHROME_BIN` is not set.

## Common causes

- Chrome/Chromium not installed or `CHROME_BIN` not set
- Running as root in Docker without `--no-sandbox`
- A test hangs (infinite loop, never-resolving promise)
- Low memory/CPU in CI causing timeouts
- Browser launch flags missing in `karma.conf.js`

## Quick fix

1. Use a custom launcher: `ChromeHeadlessCI` with `--no-sandbox`
2. Install Chrome and set `CHROME_BIN`
3. Find the hanging spec by running tests one by one (`fdescribe`)

## Detailed fix by platform

### Angular CLI

1. `ng test --watch=false --browsers=ChromeHeadlessCI`

### Linux

1. `export CHROME_BIN=$(which chromium)` or install Chrome in the CI image

## Code examples

### karma.conf.js launcher

```javascript
browsers: ['ChromeHeadlessCI'],
customLaunchers: {
  ChromeHeadlessCI: { base: 'ChromeHeadless', flags: ['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage'] },
},
browserNoActivityTimeout: 120000,
```

## How to diagnose

1. **Browser** — Is Chrome found (CHROME_BIN)?
2. **Sandbox** — Running as root/in Docker?
3. **Hang** — Which spec blocks?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/angular/karma-disconnected-no-captured-browser)
