> ## Documentation Index
> Fetch the complete documentation index at: https://docs.browserbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Timeout

> Extend session duration beyond the default timeout period.

By default, Browserbase sessions have a timeout period after which they automatically terminate, which prevents sessions from running forever unexpectedly.

You can **extend this duration** either project-wide or per-session. The session still ends when it reaches its timeout.

> [!NOTE]
>
> The maximum session duration is 6 hours. When a session times out, you'll see a `TimeoutError`: `Timeout _____ms exceeded`.

## Project-wide timeout

You can change the default session timeout for all sessions in your project through the dashboard settings.

![](https://mintcdn.com/browserbase/Qn5OB0mYcUstQ-qY/images/long-running-sessions/defaulttimeout.png?fit=max\&auto=format\&n=Qn5OB0mYcUstQ-qY\&q=85\&s=ff72c98040cd5551fb643356b2d41a7b)

![](https://mintcdn.com/browserbase/m1Ny8qOvNHvtrY7y/images/long-running-sessions/toggle.png?fit=max\&auto=format\&n=m1Ny8qOvNHvtrY7y\&q=85\&s=be3ed147f0ea4bfa4b48f901aeb0a500)

## Per-session timeout

Set `timeout` in the HTTP request body, or `api_timeout` in the Node.js and Python SDKs, to specify the session duration in seconds. The SDK request option `timeout` controls how long the client waits for an API response; it does not set the browser session duration.

This is useful when different sessions need different timeouts, or when you need more granular control than the dashboard toggle provides.

> [!NOTE]
>
> The examples below set timeout to 3600 seconds (1 hour), overriding the project default. Unless explicitly closed beforehand, the session continues running for an hour before terminating. At disconnect, it ends.

> [tab] Node.js
>
> ```typescript Node.js theme={null}
> import Browserbase from "@browserbasehq/sdk";
>
> const bb = new Browserbase({
>   apiKey: process.env.BROWSERBASE_API_KEY!,
> });
>
> // Creates a session with a timeout of 3600 seconds (1 hour)
> const session = await bb.sessions.create({
>   api_timeout: 3600,
> });
> ```
>
> ```typescript Node.js theme={null}
> const options = {
>   method: "POST",
>   headers: {
>     "X-BB-API-Key": "<your-api-key>",
>     "Content-Type": "application/json",
>   },
>   body: '{"timeout": 3600}',
> };
>
> fetch("https://api.browserbase.com/v1/sessions", options)
>   .then((response) => response.json())
>   .then((response) => console.log(response))
>   .catch((err) => console.error(err));
> ```

> [tab] Python
>
> ```python Python theme={null}
> from browserbase import Browserbase
> import os
>
> bb = Browserbase(api_key=os.environ["BROWSERBASE_API_KEY"])
>
> # Creates a session with a timeout of 3600 seconds (1 hour)
> session = bb.sessions.create(api_timeout=3600)
> ```
>
> ```python Python theme={null}
> import os
> import requests
>
> headers = {
>     "x-bb-api-key": os.environ["BROWSERBASE_API_KEY"],
> }
> json = {
>     "timeout": 3600,
> }
>
> response = requests.post(
>     "https://api.browserbase.com/v1/sessions", json=json, headers=headers
> )
>
> response.raise_for_status()
> print(response.json())
> ```

## Timeouts and keep alive

Setting a custom timeout extends how long a session can run, but the session still terminates when you disconnect.

If you need to **disconnect and reconnect** to the same session, use [Keep Alive](https://docs.browserbase.com/platform/browser/long-sessions/keep-alive.md) instead. For sessions that need both extended duration and reconnection support, configure both options:

```typescript Node.js theme={null}
const session = await bb.sessions.create({
  keepAlive: true,
  api_timeout: 3600, // 1 hour
});
```

> [card] [Keep alive](https://docs.browserbase.com/platform/browser/long-sessions/keep-alive.md)
>
> Learn how to keep sessions alive across disconnects.

> [card] [Manage browser sessions](https://docs.browserbase.com/platform/browser/getting-started/manage-browser-session.md)
>
> Monitor session state and release browsers when work finishes.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.