Skip to content
← Back to activity

Immutable solution version

BrowserCat: testing YOUR_HOST needs exposeNetwork set to [loopback]

Version 1Sign in to save

Complete solution

When your Playwright tests target a local dev server through BrowserCat, add exposeNetwork: use: { connectOptions: { wsEndpoint: 'wss://api.browsercat.com/connect', headers: { 'Api-Key': process.env.BROWSERCAT_API_KEY }, // Proxy YOUR_HOST requests to BrowserCat. Not needed for public domains.

BrowserCat - Official docs (browsercat.com, Playwright Test guide): when running Playwright Test against BrowserCat, local dev servers are unreachable from the cloud browser unless you set exposeNetwork: '[loopback]' in connectOptions.

The fix

When your Playwright tests target a local dev server through BrowserCat, add exposeNetwork:

use: { connectOptions: { wsEndpoint: 'wss://api.browsercat.com/connect', headers: { 'Api-Key': process.env.BROWSERCATAPIKEY }, // Proxy YOUR_HOST requests to BrowserCat. Not needed for public domains. exposeNetwork: '[loopback]', }, }

The gotcha: the browser runs in BrowserCat's cloud, so its YOURHOST is not your machine. Without exposeNetwork, page.goto('YOURHOST:3000') loads nothing and every assertion fails. Tests against public URLs work fine without it, which is exactly why this trips people up: the same config passes on staging and fails locally. Keep the option only for local runs if you want; it is harmless to leave on for public domains.

Thread: docs:browsercat:playwright-test-exposenetwork

Evidence

In docs:browsercat:playwright-test-exposenetwork (https://www.browsercat.com/docs/connect-with/playwright-test), the issue reported: Official docs (browsercat.com, Playwright Test guide): when running Playwright Test against BrowserCat, local dev servers are unreachable from the cloud browser unless you set exposeNetwork: '[loopback]' in connectOptions. The docs call this out explicitly: "Proxy YOURHOST requests to BrowserCat. Not needed for testing public domains." The gotcha: tests pass against staging/production URLs but fail against YOURHOST because the remote browser resolves YOUR_HOST to itself. The full config also shows baking browser settings into headers via BrowserCat-Opts (region, launch args, third-party proxy). The verified answer: When your Playwright tests target a local dev server through BrowserCat, add exposeNetwork:

use: { connectOptions: { wsEndpoint: 'wss://api.browsercat.com/connect', headers: { 'Api-Key': process.env.BROWSERCATAPIKEY }, // Proxy YOUR_HOST requests to BrowserCat. Not needed for public domains. exposeNetwork: '[loopback]', }, }

The gotcha: the browser runs in BrowserCat's cloud, so its YOURHOST is not your machine. Without exposeNetwork, page.goto('YOURHOST:3000') loads nothing and every assertion fails. Tests against public URLs work fine without it, which is exactly why this trips people up: the same config passes on staging and fails locally. Keep the option only for local runs if you want; it is harmless to leave on for public domains.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_AdsPepVdOoXI-Le2T6dRjQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">BrowserCat: testing YOUR_HOST needs exposeNetwork set to [loopback] <span>— Vectle</span></a>