# Configure TrueProxies with Browser Use

> Run Browser Use agents through TrueProxies with ProxySettings on Browser, including country targeting and a sticky exit per agent run.

Source: https://docs.trueproxies.com/integrations/browser-use/

> **Use your own endpoints**
>
> The examples below use placeholders. Copy the connection host, ports, username, and proxy password from the **Username and password** tab of your service in the dashboard. See [How to connect](https://docs.trueproxies.com/proxy-instructions/how-to-connect/#connection-host-and-ports).

Browser Use takes a proxy on the `Browser` it launches: pass `ProxySettings(server=..., username=..., password=...)` as `proxy`. Browser Use starts Chromium with the proxy server and answers the proxy’s authentication challenge with your username and proxy password, so no browser extension is needed. Use the HTTP port; targeting rides on the username.

## Installation

```bash
uv pip install browser-use
uvx browser-use install
```

`uvx browser-use install` installs Chromium. The example uses `ChatBrowserUse`, which reads `BROWSER_USE_API_KEY` from the environment; any chat model Browser Use supports works the same way with the proxy.

## Basic usage

```python
import asyncio

from browser_use import Agent, Browser, ChatBrowserUse
from browser_use.browser import ProxySettings

browser = Browser(
    proxy=ProxySettings(
        server="http://YOUR_HOST:YOUR_HTTP_PORT",
        username="your_username",
        password="your_password",
    ),
)


async def main() -> None:
    agent = Agent(
        task="Open https://httpbin.org/ip and report the IP address shown",
        llm=ChatBrowserUse(),
        browser=browser,
    )
    await agent.run()


asyncio.run(main())
```

The agent reports the exit IP address. The proxy applies to the browser’s traffic only; the agent’s calls to the chat model do not go through it.

## Residential IPv4 country targeting

```python
browser = Browser(
    proxy=ProxySettings(
        server="http://YOUR_HOST:YOUR_HTTP_PORT",
        username="your_username-country-us",
        password="your_password",
    ),
)
```

## Residential IPv4 sticky session per agent run

Without a `session` option, each new connection gets a new exit IP, so one agent run can reach a site from several addresses. Give each run its own session to keep one exit for the whole task:

```python
import uuid

session = uuid.uuid4().hex[:16]  # 1 to 32 letters or digits

browser = Browser(
    proxy=ProxySettings(
        server="http://YOUR_HOST:YOUR_HTTP_PORT",
        username=f"your_username-session-{session}-lifetime-1800",
        password="your_password",
    ),
)
```

`lifetime` is in seconds. The accepted range depends on the product; see the [options table](https://docs.trueproxies.com/proxy-instructions/how-to-connect/#options).

## When the browser cannot connect

A refused proxy connection reaches the agent as a browser network error, and the browser does not show the proxy’s reason. Send the same username and proxy password with `curl -v`, read the `X-Proxy-Reason` header, and look it up in [Proxy errors and refusal reasons](https://docs.trueproxies.com/proxy-instructions/errors/).

## Related guides

- [Connection and username format](https://docs.trueproxies.com/proxy-instructions/how-to-connect/)
- [HTTP CONNECT and SOCKS5](https://docs.trueproxies.com/proxy-instructions/proxy-protocols/)
- [Trusted IPs](https://docs.trueproxies.com/proxy-instructions/trusted-ips/)
- [Proxy errors and refusal reasons](https://docs.trueproxies.com/proxy-instructions/errors/)
- [Troubleshooting checklist](https://docs.trueproxies.com/support/)
