Skip to content

Automate browser based workflows with AI

4.5 KB
Raw Blame
---
title: Connect Skyvern to Your Local Browser
subtitle: Run automations using your existing cookies, logins, and extensions
slug: running-tasks/connect-local-browser
---

## Why connect your local browser?

With `skyvern browser serve`, Skyvern Cloud can control a Chrome browser running on your machine — using your existing cookies, sessions, extensions, and saved passwords. This is useful when:

- You need to automate a site where you're already logged in
- The target site is behind a VPN or firewall that only your machine can reach
- You want Skyvern to use browser extensions you've already installed

## Quick start

```bash
skyvern browser serve --tunnel
```

This launches Chrome on your machine, starts a CDP proxy server, and creates an ngrok tunnel so Skyvern Cloud can connect automatically.

> The `--tunnel` flag requires [ngrok](https://ngrok.com/download) installed and authenticated (`ngrok authtoken <your-token>`).

### Manual tunnel setup

```bash
# 1. Start the browser server
skyvern browser serve

# 2. In a separate terminal, create a tunnel
ngrok http 9222

# 3. Copy the ngrok URL and use it as browser_address in your task
```

## Run a task on your local browser

Pass the tunnel URL as `browser_address`:

```python
from skyvern import Skyvern

skyvern = Skyvern(api_key="YOUR_API_KEY")

result = await skyvern.run_task(
    prompt="Download the latest invoice from my account",
    browser_address="wss://abc123.ngrok-free.dev",
)
```

## How it works

```
┌──────────────────────────────────────────────────────┐
│  Your machine                                        │
│                                                      │
│  ┌────────────┐   CDP (internal)   ┌──────────────┐  │
│  │   Chrome    │◄─────────────────►│  Unified     │  │
│  │  (port      │   port 10222      │  Server      │  │
│  │   10222)    │                   │  (port 9222) │  │
│  └────────────┘                   └──────┬───────┘  │
│                                          │           │
└──────────────────────────────────────────┼───────────┘
                                           │
                              ngrok / tunnel│
                                           │
                                    ┌──────▼───────┐
                                    │ Skyvern Cloud│
                                    └──────────────┘
```

1. **Launches Chrome** with CDP enabled on an internal port (`exposed_port + 1000`)
2. **Starts a proxy server** on the exposed port (default `9222`) that forwards CDP traffic to Chrome
3. **Optionally creates a tunnel** (`--tunnel`) so Skyvern Cloud can reach it from the internet

## CLI options

| Option | Default | Description |
|---|---|---|
| `--port` | `9222` | Port for the proxy server. Chrome uses `port + 1000` internally. |
| `--profile-dir` | `~/.skyvern/chrome-profile` | Chrome user data directory. Point this at an existing profile to reuse cookies and logins. |
| `--download-dir` | `~/.skyvern/downloads/{browser_id}` | Directory for browser downloads. |
| `--api-key` | (none) | API key for authenticating incoming requests. |
| `--headless` | `false` | Run Chrome in headless mode (no visible window). |
| `--chrome-path` | (auto-detect) | Path to Chrome/Chromium executable. |
| `--tunnel` | `false` | Automatically start an ngrok tunnel. |
| `--json` | `false` | Output connection info as JSON (for scripting). |

The `--api-key` option can also be set via the `SKYVERN_BROWSER_SERVE_API_KEY` environment variable.

## Security

> **Warning:** When you run `skyvern browser serve` without `--api-key` and expose it via a tunnel, anyone with the tunnel URL has full remote control of your Chrome browser — including access to all logged-in sessions, cookies, and saved passwords.

Always use `--api-key` when exposing your browser:

```bash
skyvern browser serve --api-key "your-skyvern-api-key" --tunnel
```

Skyvern Cloud automatically sends the correct API key when connecting. For additional security (IP allowlisting, mTLS, VPN), contact **[email protected]**.