---
source_url: https://www.pubnub.com/docs/sdks/javascript/status-events
title: Status Events for JavaScript SDK
updated_at: 2026-06-04T11:12:00.360Z
sdk_name: PubNub JavaScript SDK
sdk_version: 11.0.1
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Status Events for JavaScript SDK

PubNub JavaScript SDK, use the latest version: 11.0.1

Install:

```bash
npm install pubnub@11.0.1
```

The PubNub JavaScript Software Development Kit (SDK) reports status events for subscription and connectivity. This page summarizes which statuses you can expect based on your subscription architecture.

:::warning Subscribe loop
The SDK emits different statuses depending on the subscription architecture in use. The new subscription workflow is enabled by default as of JavaScript SDK version `11.0.0`. To use the legacy subscription manager, set [enableEventEngine: false](https://www.pubnub.com/docs/sdks/javascript/api-reference/configuration#enable-event-engine).
:::

The PubNub JavaScript SDK emits statuses to notify you about the state of the SDK.

:::tip SDK connection lifecycle
For more general information on statuses and reconnection policies, refer to [SDK Connection Lifecycle](https://www.pubnub.com/docs/general/setup/connection-management#sdk-connection-lifecycle).
:::

## Available statuses

Depending on whether [enableEventEngine](https://www.pubnub.com/docs/sdks/javascript/api-reference/configuration#enable-event-engine) is `true` or `false`, the SDK emits different statuses.

### enableEventEngine: true (default)

| Status | Description | Introduced in version |
| --- | --- | --- |
| `PNConnectedCategory` | PubNub client subscribed and is ready to receive real-time updates. This is emitted when the subscription is started (handshake success). Channel or channel group mix changes emit `PNSubscriptionChangedCategory`. | before 4.0.6 |
| `PNDisconnectedCategory` | PubNub client intentionally disconnected from the real-time updates stream. | before 4.0.6 |
| `PNDisconnectedUnexpectedlyCategory` | PubNub client unexpectedly disconnected from the real-time updates stream. This status may contain an `error` field that provides more information about the error. | 8.9.0 |
| `PNConnectionErrorCategory` | PubNub client wasn't able to connect to the real-time updates stream. Returned when the previously started subscribe loop failed, and the client disconnected from real-time data channels. It can happen because of permissions errors or because the network is down. This status may contain an `error` field that provides more information about the error. | before 4.0.6 |
| `PNSubscriptionChangedCategory` | The mix of subscribed channels and channel groups has changed. This event returns two arrays: one with all currently subscribed channels and the second with all currently subscribed channel groups. | 9.5.0 |

:::tip SDK connection lifecycle
Intermediate states like connecting and reconnecting are now handled internally without emitting specific statuses. For more general information on statuses and reconnection policies, refer to [SDK Connection Lifecycle](https://www.pubnub.com/docs/general/setup/connection-management#sdk-connection-lifecycle).
:::

### enableEventEngine: false (legacy)

| Status | HTTP Code | Description |
| --- | --- | --- |
| `PNConnectedCategory` | 200 | PubNub client subscribed with a new mix of channels and is ready to receive real-time updates. This is fired every time the channel or channel group mix changes and upon connecting to the real-time updates stream for the first time. |
| `PNDisconnectedCategory` | n/a | PubNub client intentionally disconnected from the real-time updates stream. |
| `PNNetworkIssuesCategory` | n/a | PubNub client wasn't able to reach PubNub servers because the machine or device isn't connected to the internet due to a network issue or the client is behind a proxy. For the subscribe loop, this information is provided as a part of the `error` field for received `PNConnectionErrorCategory` or `PNDisconnectedUnexpectedlyCategory` statuses. |
| `PNBadRequestCategory` | 400 | PubNub client wasn't initialized with the `publishKey`, the `channel` or `message` or both are missing from the payload, or the request is otherwise malformed. |
| `PNReconnectedCategory` | 200 | PubNub client was able to reconnect to PubNub and is ready to receive real-time updates. |
| `PNAccessDeniedCategory` | 403 | PubNub client wasn't able to process a request because the authorization key doesn't have read permissions for the required resources ([Access Manager](https://www.pubnub.com/docs/general/security/access-control) permission failure). For the subscribe loop, this information is provided as a part of the `error` field for received `PNConnectionErrorCategory` or `PNDisconnectedUnexpectedlyCategory` statuses. |
| `PNTimeoutCategory` | n/a | PubNub client failed to establish a connection to PubNub due to a timeout (server didn't respond within the specified time frame). |
| `PNRequestMessageCountExceededCategory` | n/a | PubNub client exceeded the configured [requestMessageCountThreshold](https://www.pubnub.com/docs/sdks/javascript/api-reference/configuration#initialization) (in-memory cache messages). It may suggest that you should enable [Message Persistence](https://www.pubnub.com/docs/general/storage) on the keyset. |
| `PNUnknownCategory` | Other | PubNub client received an unexpected response or encountered an error that couldn't be categorized. Common causes: aborted requests (check `errorData` for `[Error: Aborted]`), non-standard HTTP responses from proxies/VPNs, malformed JSON from intermediate actors, or unhandled HTTP status codes. Check the `statusCode` and `errorData` fields for details. For the subscribe loop, this information is provided as a part of the `error` field for received `PNConnectionErrorCategory` or `PNDisconnectedUnexpectedlyCategory` statuses. |
| `PNCancelledCategory` | n/a | PubNub client cancelled the request. This can occur when a request is explicitly cancelled or when the browser/application aborts an in-flight request (for example, during page navigation). |
| `PNValidationErrorCategory` | n/a | PubNub client provided incomplete parameters for a particular endpoint. |
| `PNMalformedResponseCategory` | n/a | PubNub client received an unexpected response from PubNub or an intermediate actor (such as a proxy or VPN). For the subscribe loop, this information is provided as a part of the `error` field for received `PNConnectionErrorCategory` or `PNDisconnectedUnexpectedlyCategory` statuses. |
| `PNServerErrorCategory` | 5xx | PubNub server returned an error. This may indicate a temporary server issue or an ongoing incident. |

## Browser-specific statuses

You can [configure](https://www.pubnub.com/docs/sdks/javascript/api-reference/configuration#listen-to-browser-network-events) the SDK to emit the following additional statuses when the network status changes in the browser environment.

It doesn't matter if `enableEventEngine` is `true` or `false`, the SDK emits the same browser-specific statuses.

| Status | Description |
| --- | --- |
| `PNNetworkDownCategory` | The internet connection isn't available, or PubNub servers aren't reachable. |
| `PNNetworkUpCategory` | The internet connection is available, and PubNub servers are reachable. |

:::tip Handling 403 errors in subscribe
If you receive 403 (Access Denied) errors during subscription, they appear as `PNConnectionErrorCategory` with `PNAccessDeniedCategory` in the nested `error` field. Verify your [Access Manager](https://www.pubnub.com/docs/general/security/access-control) token has read permissions for the subscribed channels.
:::

## Migrating to the new subscription loop

:::note When to migrate
If you are upgrading from a version prior to `11.0.0` where `enableEventEngine` defaulted to `false` and your application inspects status categories, review the changes below. No action is required if your listeners do not inspect `PNConnectedCategory` beyond detecting the initial connection.
:::

When the SDK uses the new subscription loop (`enableEventEngine: true`), the only user-facing change is subscription status events.

Messages, presence, and all other APIs work exactly as before. Only the status categories emitted by the subscription have changed. There are fewer categories, richer error detail, and no more ambiguity between first-connect and reconnect.

No action is required if your application doesn't inspect status categories in its listener. If you rely on `PNConnectedCategory` to mean "channels or groups were added or removed," read on.

#### Key status change: PNConnectedCategory

| Before (legacy) | After (new subscription loop) |
| --- | --- |
| `PNConnectedCategory` fired on every subscription change (adding or removing channels or channel groups). | `PNConnectedCategory` is emitted **only when the subscription is started**. Subsequent channel mix changes emit `PNSubscriptionChangedCategory` instead. |

:::warning Update listener logic if you rely on connection status
If your application treats `PNConnectedCategory` as "subscription list changed" or runs logic on every subscribe/unsubscribe, switch that logic to `PNSubscriptionChangedCategory`. Use `PNConnectedCategory` only for the initial subscription start.
:::

#### New statuses

| Status | Description |
| --- | --- |
| `PNSubscriptionChangedCategory` | Fires when channels or channel groups are added or removed after the initial subscription. Returns arrays of all currently subscribed channels and groups. |
| `PNDisconnectedUnexpectedlyCategory` | The client lost its real-time connection unexpectedly. Inspect the `error` field for root-cause details. |
| `PNConnectionErrorCategory` | The client was unable to establish or re-establish the real-time connection. The `error` field contains specifics (e.g. 403, timeout, network failure). |

#### Listener migration example

##### Before (legacy: PNConnectedCategory on every change)

```javascript
pubnub.addListener({
  status: (statusEvent) => {
    if (statusEvent.category === 'PNConnectedCategory') {
      // This ran on first connect AND every time channels/groups were added or removed
      console.log('Subscription updated:', statusEvent.affectedChannels, statusEvent.affectedChannelGroups);
    }
  }
});
```

##### After (new subscription loop)

```javascript
pubnub.addListener({
  status: (statusEvent) => {
    if (statusEvent.category === 'PNConnectedCategory') {
      console.log('Subscribed and ready');
    }
    if (statusEvent.category === 'PNSubscriptionChangedCategory') {
      console.log('Subscription updated:', statusEvent.affectedChannels, statusEvent.affectedChannelGroups);
    }
  }
});
```

Migration steps:

1. Set enableEventEngine to true in your config.
2. If you inspect statusEvent.category, add handling for PNSubscriptionChangedCategory for channel/group add/remove; reserve PNConnectedCategory for the initial subscription start only.
3. Optionally handle PNDisconnectedUnexpectedlyCategory and PNConnectionErrorCategory and use their error field for diagnostics.
4. Test your application to ensure it handles the new statuses correctly.