# Docs: Self-hosting The full text of every page in this group of the Steel docs. The [docs sitemap](https://steel.dev/docs/sitemap.md) lists every page under the same group names, and links the full text of each group. ## Docs: Steel Browser https://steel.dev/docs/self-hosting/steel-browser > Steel Browser is the open-source browser API that you can run yourself. See how it differs from Steel Cloud and when to choose it. Steel Browser is Steel's open-source browser API. It runs one Chrome browser behind a REST API, on a machine that you control. The code is on [GitHub](https://github.com/steel-dev/steel-browser) under the Apache 2.0 license. Steel Cloud is the service at `api.steel.dev`. Steel runs its browsers for you, adds features that Steel Browser does not have, and bills you for usage. With Steel Browser, you run the browser yourself, and you take care of its capacity, updates and security. ### What you get Steel Browser is a Node.js server that starts Chrome and controls it with Puppeteer over CDP (Chrome DevTools Protocol). It serves its API on port `3000`. The Docker image includes Chromium, so you do not need a browser on the host. For the features that both have, Steel Browser uses the same API paths as Steel Cloud: - Sessions, with `POST /v1/sessions` and options such as `proxyUrl`, `blockAds`, `dimensions` and `userAgent`. You can list, read and release sessions. - Quick actions, `POST /v1/scrape`, `/v1/screenshot` and `/v1/pdf`, which work on a page in one request. - Commands, at `POST /v1/sessions/{sessionId}/commands`, which drive the session. They are Experimental and off by default. See [Configuration](https://steel.dev/docs/self-hosting/configuration#enable-the-commands-api). - Session files, under `/v1/sessions/{sessionId}/files`, which move files in and out of the browser. Playwright and Puppeteer connect to a session's `websocketUrl`, as they do with Steel Cloud. The TypeScript and Python Steel SDKs work with Steel Browser for sessions, scrapes and session files when you change their base URL. See [Create a session](https://steel.dev/docs/self-hosting/docker#create-a-session). Screenshots and PDFs work differently. Steel Browser's `/v1/screenshot` and `/v1/pdf` return the image or the PDF file itself, while Steel Cloud returns JSON with the file's `url`. The SDK's `screenshot` and `pdf` methods expect that JSON, so call these two endpoints with an HTTP client and save the response body. A scrape with `screenshot` or `pdf` set returns each file as a base64 string, not as an object with a `url`. Steel Browser also has a UI to watch the browser, at `/ui` in the single Docker image. Its OpenAPI documentation, at `/documentation`, describes the API of the version that you run. Steel Browser runs one browser, so it has one session at a time. Creating a session ends the session that is running. Steel Browser does not check an API key, so anyone who can reach its ports can control the browser. ### How Steel Browser differs from Steel Cloud Steel Browser and Steel Cloud are separate code bases, and they change separately. For the API of the version that you run, see `/documentation` on your instance. | Feature | Steel Cloud | Steel Browser | | - | - | - | | Sessions at the same time | Depends on the plan. See [Limits](https://steel.dev/docs/platform/limits). | One | | Authentication | An API key on every request | None | | Screenshot and PDF responses | JSON with the file's `url` | The file itself | | Proxies | [Steel proxies](https://steel.dev/docs/stealth/proxies) and your own proxy | Your own proxy, with `proxyUrl` | | [Dedicated IPs](https://steel.dev/docs/stealth/dedicated-ips) | Yes | No. The browser uses the host's network. | | [CAPTCHA solving](https://steel.dev/docs/stealth/captcha-solving) | Yes | No | | Bot detection | Steel's [fingerprints](https://steel.dev/docs/stealth/fingerprints) and stealth features | Basic: stealth plugins and fingerprint injection | | [Commands](https://steel.dev/docs/control/commands) | Yes | Off by default. Turn it on with `ENABLE_COMMANDS_API=true`. | | [Extensions](https://steel.dev/docs/sessions/extensions) | Upload them with the Extensions API | Put them in the `api/extensions` folder, build the image, and name them in the `extensions` option of the session | | [Profiles](https://steel.dev/docs/logins/profiles) | Profiles API | No Profiles API. `persist: true` keeps one browser data folder. | | [Credentials](https://steel.dev/docs/logins/credentials) | Yes | No | | [Files](https://steel.dev/docs/sessions/files) | The Files API and session files | Session files only | | [Live view](https://steel.dev/docs/observability/live-view) | Yes | A UI at `/ui` | | [Agent traces](https://steel.dev/docs/observability/agent-traces), [signals](https://steel.dev/docs/observability/signals), [session cost](https://steel.dev/docs/production/session-cost) | Yes | No | | [MCP server](https://steel.dev/docs/control/mcp-server) | Hosted at `https://mcp.steel.dev/mcp` | No | | Updates and capacity | Steel handles them | You handle them | ### When to self-host Self-host when the browser must run on your own network, for example to reach an application that is not on the internet. The browser then uses your network's DNS, routes and IP address. Self-host to develop and test against a browser on your own machine, or when you want to change the server itself. Steel Browser is open source, so you can read and change every part of it. Choose Steel Cloud when you need many sessions at the same time, Steel proxies, CAPTCHA solving, profiles or credentials, or when you do not want to run and secure the servers. Your code changes little between the two, because the Steel SDK takes a base URL and the shared parts have the same paths. To start, [run Steel Browser with Docker](https://steel.dev/docs/self-hosting/docker) on your machine or on a server that you manage. ## Docs: Run with Docker https://steel.dev/docs/self-hosting/docker > Start Steel Browser on your own machine or server with Docker, then create a session against your local API. The Docker image of [Steel Browser](https://steel.dev/docs/self-hosting/steel-browser) runs the browser API, Chromium and the UI in one container. Use it to develop against a browser on your own machine, or to run Steel Browser on a server that you manage. It needs no Steel account and no API key. ### Before you begin You need: - Docker 20.10.0 or later - at least 4 GB of memory and 10 GB of free disk space - Node.js or Python for the program on this page Install the Steel SDK and Playwright. The program connects to the browser in the container, so you do not run `playwright install`. **TypeScript** ```sh npm install steel-sdk playwright ``` **Python** ```sh python3 -m venv .venv source .venv/bin/activate pip install steel-sdk playwright ``` ### Start the container Run the image from the GitHub Container Registry: ```sh docker run --rm --name steel-browser \ -p 127.0.0.1:3000:3000 \ -p 127.0.0.1:9223:9223 \ ghcr.io/steel-dev/steel-browser:latest ``` The API listens on port `3000`, and port `9223` is for the Chrome debugger. The `127.0.0.1` in each `-p` makes both ports reachable only from your machine. `--rm` removes the container when it stops. > **Warning** > > Steel Browser does not check an API key. Anyone who can reach port `3000` or `9223` can control the browser. Do not open these ports to the internet without authentication and TLS in front of them. Check that the API is up: ```sh curl http://localhost:3000/v1/health ``` When the browser is up, the API returns: ```json nocopy {"status":"ok"} ``` The UI is at `http://localhost:3000/ui`, and the API documentation is at `http://localhost:3000/documentation`. The repository publishes the image with the tag `latest` only, and it builds a new one on each change to its `main` branch. #### Run the API and the UI as two containers The repository also has a Docker Compose file that runs the API and the UI as separate containers. It stores browser logs in a volume. Clone the repository: ```sh git clone https://github.com/steel-dev/steel-browser.git cd steel-browser ``` The compose file publishes ports `3000`, `9223` and `5173` on all of the host's network interfaces. Before you start it, edit the `ports` lists in `docker-compose.yml` so that each entry starts with `127.0.0.1:`: ```yaml services: api: ports: - "127.0.0.1:3000:3000" - "127.0.0.1:9223:9223" ui: ports: - "127.0.0.1:5173:80" ``` Then start the containers: ```sh docker compose up ``` The API is at `http://localhost:3000` and the UI at `http://localhost:5173`. If you reach the server through another host name, for example behind a reverse proxy with authentication, copy `.env.example` to `.env` and set `DOMAIN` and `CDP_DOMAIN` to that host. Docker Compose fills them into the compose file. See [Configuration](https://steel.dev/docs/self-hosting/configuration). ### Create a session The Steel SDK sends requests to `https://api.steel.dev` by default. Point it at your instance with its base URL: `baseURL` in TypeScript, `base_url` in Python. Every Steel SDK also reads the base URL from the `STEEL_BASE_URL` environment variable. Then create a session and connect Playwright to its `websocketUrl`. This program creates a session, opens a page, prints its title, and releases the session. **TypeScript** ```ts file=local.mts import Steel from "steel-sdk"; import { chromium } from "playwright"; const client = new Steel({ baseURL: "http://localhost:3000" }); const session = await client.sessions.create(); try { const browser = await chromium.connectOverCDP(session.websocketUrl); const context = browser.contexts()[0]; const page = context.pages()[0] ?? (await context.newPage()); await page.goto("https://example.com"); console.log(await page.title()); await browser.close(); } finally { await client.sessions.release(session.id); } ``` **Python** ```python file=local.py from playwright.sync_api import sync_playwright from steel import Steel client = Steel(base_url="http://localhost:3000") session = client.sessions.create() try: with sync_playwright() as playwright: browser = playwright.chromium.connect_over_cdp(session.websocket_url) context = browser.contexts[0] page = context.pages[0] if context.pages else context.new_page() page.goto("https://example.com") print(page.title()) browser.close() finally: client.sessions.release(session.id) ``` Run the program: **TypeScript** ```sh npx tsx local.mts ``` **Python** ```sh python local.py ``` The program prints the page title: ```text nocopy Example Domain ``` A local session's `websocketUrl` is `ws://localhost:3000/`. It has no API key in it, because Steel Browser does not need one. To watch the session while the program runs, open `http://localhost:3000/ui`. Steel Browser runs one session at a time. To stop the container, run `docker stop steel-browser`. ### Check that it worked Print `session.websocketUrl` (`session.websocket_url` in Python) in the program. It is `ws://localhost:3000/`, the address of your container, and not a `wss://connect.steel.dev` URL of Steel Cloud. So the session ran in your container, and the title that the program prints came from its browser. ### Next steps - [Configuration](https://steel.dev/docs/self-hosting/configuration): Set your instance's environment variables and session options, and turn on its Commands API. - [CLI](https://steel.dev/docs/control/cli#run-against-a-self-hosted-instance): Run `steel` commands against your instance with `--api-url` or `--local`. ## Docs: Configuration https://steel.dev/docs/self-hosting/configuration > Configure a self-hosted Steel Browser instance with environment variables and session options, and turn on its Commands API. Environment variables control where a self-hosted [Steel Browser](https://steel.dev/docs/self-hosting/steel-browser) server listens, how it starts Chrome, what it logs, and whether it serves the Commands API. Session options choose the extensions that a session loads and where it keeps browser data. Your instance's OpenAPI documentation, at `/documentation`, lists every session option. ### Environment variables Set a variable with `-e` on `docker run`, as in [Enable the Commands API](https://steel.dev/docs/self-hosting/configuration#enable-the-commands-api), or under `environment:` of the `api` service in a Docker Compose file. A `.env` file next to the compose file only fills the `${...}` values in it, such as `${DOMAIN}`. Docker Compose does not pass the file to the container. When you run the server from source, it reads a `.env` file from the folder that you start it in. A variable of the type "flag" is on when its value is `true` or `1`. #### Server and URLs | Variable | Type | Default | Meaning | | - | - | - | - | | `NODE_ENV` | `test`, `development`, `staging`, `production` or `preview` | `development`. The Docker image sets `production`. | With `production`, the server serves the UI at `/ui`. With `development`, it keeps session files in the system's temporary folder instead of `/files`, and it prints readable logs. | | `HOST` | text | `0.0.0.0` | The IP address that the server listens on. Chrome accepts debugger connections on the same address. | | `PORT` | number | `3000` | The port that the API listens on. | | `DOMAIN` | text | none | The host, and the port if needed, in the URLs that the server returns, such as `websocketUrl` and `sessionViewerUrl`. Without it, the server writes `HOST:PORT`, with `localhost` instead of `0.0.0.0`. Set it when the server runs behind a domain or a proxy. | | `USE_SSL` | flag | `false` | When on, the URLs that the server returns start with `https://` and `wss://`. Turn it on behind HTTPS. | | `CDP_DOMAIN` | text | `DOMAIN` | The host in the debugger URLs. | | `CDP_REDIRECT_PORT` | number | `9222`. The Docker image sets `9223`. | The port in the debugger URLs when `CDP_DOMAIN` and `DOMAIN` are not set. | | `ENABLE_COMMANDS_API` | flag | `false` | Turn on the Commands API. See [Enable the Commands API](https://steel.dev/docs/self-hosting/configuration#enable-the-commands-api). | | `KILL_TIMEOUT` | number | `0` | Read but not used. | #### Chrome | Variable | Type | Default | Meaning | | - | - | - | - | | `CHROME_EXECUTABLE_PATH` | path | Chrome's usual path on the system | The Chrome program to start. Set it when Chrome is somewhere else. | | `CHROME_HEADLESS` | flag | `true` | Run Chrome without a window. The session option `headless` overrides it for one session. | | `DISPLAY` | text | `:10` | The X display for Chrome when it runs with a window. | | `CHROME_ARGS` | text | none | Extra command-line arguments for Chrome, separated by spaces. | | `FILTER_CHROME_ARGS` | text | none | Arguments to remove from the Chrome command line, separated by spaces. | | `DISABLE_CHROME_SANDBOX` | flag | `false` | Start Chrome without its sandbox. The server also does this when it runs as root. | | `DEBUG_CHROME_PROCESS` | flag | `false` | Print the Chrome process's output and errors. | | `CHROME_USER_DATA_DIR` | path | `steel-chrome` in the system's temporary folder | The Chrome data folder for a session without `persist`. | | `CONTEXT_CACHE_TTL_MS` | number | `1000` | How long, in milliseconds, the server reuses the cookies and storage that it read from the Chrome data folder. | | `DEFAULT_HEADERS` | JSON object | `{}` | HTTP headers that the browser adds to every request from every page, such as `{"X-Team":"qa"}`. | | `DEFAULT_TIMEZONE` | time zone name | the host's time zone | The browser's time zone when the session sets none and the time zone service returns none. | | `TIMEZONE_SERVICE_URL` | URL | `https://ipinfo.io/json` | The service that the server asks for the time zone of the browser's IP address, through the session's proxy. It reads the `timezone` field of the JSON response. | | `SKIP_FINGERPRINT_INJECTION` | flag | `false` | Turn off fingerprint injection for every session. The session option `skipFingerprintInjection` turns it off for one session. | | `PROXY_INTERNAL_BYPASS` | text | none | Hosts that skip the session's proxy, separated by commas. `0.0.0.0` and `HOST` always skip it. | | `PROXY_URL` | text | none | Read but not used. Pass a proxy for each session with `proxyUrl`. | #### Logging | Variable | Type | Default | Meaning | | - | - | - | - | | `LOG_LEVEL` | `debug`, `info`, `warn` or another Pino level | `debug` | The log level with `NODE_ENV=development`. | | `ENABLE_VERBOSE_LOGGING` | flag | `false` | With `NODE_ENV=development`, adds each log call's arguments to the log line. | | `LOG_STORAGE_ENABLED` | flag | `false` | Store browser logs in a DuckDB file. The Docker Compose file turns it on. | | `LOG_STORAGE_PATH` | path | `steel-browser-logs/logs.duckdb` in the system's temporary folder | The DuckDB file for browser logs. | | `ENABLE_CDP_LOGGING` | flag | `false` | Read but not used. | | `LOG_CUSTOM_EMIT_EVENTS` | flag | `false` | Read but not used. | #### Docker image and UI | Variable | Type | Default | Meaning | | - | - | - | - | | `DEBUG` | `true` | none | In the Docker image, start DBus, check Chrome and ChromeDriver, and print each step of the startup. | | `API_URL` | URL | `http://api:3000` in the Docker Compose files | In the UI container, the URL of the API that the UI sends its requests to. | | `VITE_API_URL` | URL | `/api`. The single Docker image builds the UI with an empty value. | When you build the UI, the URL prefix of each API request that the UI sends. In the UI container, nginx forwards `/api/` to `API_URL`. | | `VITE_WS_URL` | URL | `/ws`. The single Docker image builds the UI with an empty value. | When you build the UI, the URL prefix of each WebSocket connection that the UI opens. In the UI container, nginx forwards `/ws/` to `API_URL`. | The repository's `.env.example` sets `DOMAIN=localhost:3000`, `CDP_DOMAIN=localhost:9223` and `API_URL=http://api:3000`, the three values that its compose file reads. Copy it to `.env` and change the hosts when you reach the server through another host name. Chrome always listens for debugger connections on port `9222`. In the Docker image, nginx forwards port `9223` to it, and the start script sets `CDP_REDIRECT_PORT=9223` and `DISPLAY=:10`, whatever values you pass for these two. To start the image without nginx, pass `--no-nginx` to the start script, after the image name in `docker run`. ### Enable the Commands API The Commands API drives a session with commands, as on Steel Cloud. See [Commands](https://steel.dev/docs/control/commands). In Steel Browser it is Experimental and off by default. Without `ENABLE_COMMANDS_API`, its routes do not exist. Start the server with the variable on: ```sh docker run --rm -p 127.0.0.1:3000:3000 -p 127.0.0.1:9223:9223 \ -e ENABLE_COMMANDS_API=true \ ghcr.io/steel-dev/steel-browser:latest ``` With Docker Compose, add `ENABLE_COMMANDS_API=true` under `environment:` of the `api` service. The server then has these routes: | Method | Path | Meaning | | - | - | - | | `POST` | `/v1/sessions/{sessionId}/commands` | Run commands in the session. | | `GET` | `/v1/sessions/{sessionId}/commands/executions/{executionId}` | Get an execution. The server waits up to 20 seconds for it to finish. | | `POST` | `/v1/sessions/{sessionId}/commands/executions/{executionId}/cancel` | Cancel an execution. Commands that already ran are not undone. | | `GET` | `/v1/sessions/{sessionId}/commands/schema` | The JSON Schema of the request body. | `sessionId` must be the session that the server runs. A request for another session gets `410` with the code `session_ended`. In Steel Browser, the Quick actions, `/v1/scrape`, `/v1/screenshot` and `/v1/pdf`, use the session's tabs too, so they take turns with commands: - A Quick action returns `409` while commands run or wait to run. - A commands request that arrives during a Quick action waits for it. If the request cannot start within 20 seconds, it fails with `429` and the code `expired`. - A Quick action counts as a change to the session, so the next request with `after` gets `epochChanged: true`. Pass `proxyUrl` to a Quick action to run it in a separate browser context, away from the session's tabs. On Steel Cloud, each Quick action runs in a browser of its own, so it never waits for a session's commands. `steel dev start`, in the [Steel CLI](https://steel.dev/docs/control/cli), runs the repository's Docker Compose file from `~/.config/steel/steel-browser`, and it does not turn on the Commands API. To use the `steel browser` commands with this instance, add `ENABLE_COMMANDS_API=true` under `environment:` of the `api` service in that folder's `docker-compose.yml`, and restart the instance. That compose file also publishes its ports on all network interfaces. [Run with Docker](https://steel.dev/docs/self-hosting/docker#run-the-api-and-the-ui-as-two-containers) shows how to keep them on your machine. [Commands reference](https://steel.dev/docs/reference/commands) lists the commands. ### Extensions and profiles Steel Browser has no Extensions API and no Profiles API. It loads extensions from a folder, and it keeps browser data in a folder. You choose both when you create a session. | Setting | Where | Meaning | | - | - | - | | `api/extensions/` | A folder in the repository | Holds one folder for each unpacked Chrome extension. The Docker image copies the folder at build time, so add your extension and [build the image from source](https://github.com/steel-dev/steel-browser). | | `extensions` | Session option, a list of names | The extension folders to load into the session. A name without a folder in `api/extensions/` is skipped. | | `persist` | Session option, `true` or `false` | With `true`, Chrome uses the server's `api/user-data-dir` folder, so cookies and storage stay from one session to the next. | | `userDataDir` | Session option, text | A value that is not empty has the same effect as `persist: true`. Chrome uses `api/user-data-dir`, not the path that you pass. | | `CHROME_USER_DATA_DIR` | Environment variable | The Chrome data folder for a session without `persist` or `userDataDir`. | In headless mode, the server also loads its own `recorder` extension. This request creates a session that loads the extension in `api/extensions/my-extension` and keeps its browser data: ```sh curl -X POST http://localhost:3000/v1/sessions \ -H "Content-Type: application/json" \ -d '{"extensions": ["my-extension"], "persist": true}' ``` In the Docker image, the server's code is in `/app/api`, so the data folder is `/app/api/user-data-dir`. It is inside the container, and it is gone when the container is removed. Mount a volume there to keep it.