# Errors and close codes (/browser-api/errors)

Errors come in two stages. A problem found during the handshake is an HTTP response and the WebSocket never opens. A problem during a running session closes the WebSocket with a close code.

## Handshake errors [#handshake-errors]

The response body is JSON: `{ "error", "code", "message" }`. Branch on the HTTP status and `code`, not on `message`.

| HTTP status | `code` | Meaning | What to do |
| --- | --- | --- | --- |
| 400 | `INVALID_CONNECTION_PARAMS` | A modifier is invalid, unknown, or repeated; the URL carries a query string; or `type-custom` has no `proxy`. | Fix the URL. See [Connection URL](/browser-api/connection-url). |
| 400 | `INVALID_PROFILE_ID` | The `pid` value is not a profile id issued by the server. | Use an id from the dashboard. |
| 401 | `UNAUTHORIZED` | Wrong login or password. The two are intentionally not told apart. The response has `WWW-Authenticate: Basic`. | Check the credentials in the URL. |
| 402 | `INSUFFICIENT_BALANCE` | The balance is below the first billing portion. No browser was started. | Top up, then retry. See [Billing](/browser-api/billing). |
| 403 | `ACCOUNT_SUSPENDED` | The browser account is suspended. | Contact support. |
| 409 | `PROFILE_BUSY` | The profile already has a live session. | Wait for it to end, or use another profile. |
| 409 | `SESSION_IN_USE` | Another client is connected to this `session-<id>`. | Use a different session id, or disconnect the other client. |
| 409 | `PROFILE_LIMIT_REACHED` | The account has reached its profile limit. | Delete unused profiles. |
| 429 | `CONCURRENCY_LIMIT` | The account has too many concurrent sessions. | Wait for a session to end, then retry. |
| 429 | `RATE_LIMITED` | Too many connection attempts, also after repeated wrong passwords. | Back off, then retry. |
| 503 | `PROXY_UNREACHABLE` | The customer proxy is unreachable or is not a public address. | Check the proxy URL. |
| 503 | `GEO_PROBE_FAILED` | The exit location could not be verified. No session is started and nothing is billed. | Retry; try another country or type if it persists. |
| 503 | `NO_CAPACITY` | No browser capacity right now. The response has `Retry-After`. | Retry after the indicated delay. |
| 503 | `NO_ROUTE` | There is no route for the requested class and country; the message names both. | Choose another class or country. |
| 503 | `CLASS_UNAVAILABLE` | The requested network class is not available right now. | Choose another class. |
| 503 | `RATE_LIMIT_UNAVAILABLE` | Connection rate limiting is temporarily unavailable. | Retry with backoff. |

Retry only the statuses that can change on their own: `429` and `503` (except `503 PROXY_UNREACHABLE`, which needs a working proxy). Honor `Retry-After` when present. Do not retry `400`, `401`, `403`, or `409` without a change.

## WebSocket close codes [#websocket-close-codes]

After the WebSocket has opened, it can close with one of these codes.

| Code | Name | Meaning |
| --- | --- | --- |
| 1000 | Normal | The session ended normally. |
| 1008 | Policy violation | A frame was not valid CDP, a message was larger than 8 MB, or the session exceeded the traffic ceiling. |
| 1011 | Internal error | An internal error occurred, or the browser closed. |
| 1013 | Try again later | Backpressure: the connection could not keep up. Slow down and retry. |
| 4402 | `INSUFFICIENT_BALANCE` | The balance ran out during the session. |
| 4410 | Session ended | The session was ended by the platform. The close reason names why: `MAX_DURATION`, `IDLE_TIMEOUT`, `KILLED`, `ACCOUNT_SUSPENDED`, `DELETED`, `WORKER_SHUTDOWN`, `BROWSER_CRASHED`, and others. |
| 4412 | `WORKER_LOST` | The machine that held the browser disappeared. |

After `4410` or `4412`, connect again to start a new browser.

## CDP errors [#cdp-errors]

A blocked CDP command is **not** a close: the socket stays open and the command answers an error with code `-32000` and a message starting with `POLICY_BLOCKED:`. See [Blocking policy](/browser-api/blocking-policy).