Skip to main content

Access Localhost and Internal Networks Using Tunnel

Create encrypted tunnels between your local machine and Browser Cloud. Let cloud browsers reach localhost dev servers, staging environments, and private network resources.

Why You Need This

Your cloud browser can only reach public URLs by default. But your agent may need to access localhost, staging servers, or internal tools. For example:

  • Test a local development server before deploying
  • Access a staging environment behind a corporate VPN
  • Interact with internal tools and dashboards
  • Work with a local API backend

The Tunnel Service solves this by creating an encrypted connection between your local machine and TestMu AI's cloud infrastructure. Once the tunnel is running, your TestMu AI Browser Cloud sessions can reach any URL that your machine can reach - including localhost, private IPs, and internal hostnames.

Cloud Browser --(encrypted tunnel)--> Your Machine --> localhost:3000
--> staging.internal.company.com
--> 192.168.1.50:8080

The easiest approach. Set tunnel: true in your session config and the TestMu AI Browser SDK handles starting and routing the tunnel automatically:

const session = await client.sessions.create({
adapter: 'puppeteer',
tunnel: true,
tunnelName: 'my-tunnel', // Optional: name for identification
lambdatestOptions: { ... }
});

const browser = await client.puppeteer.connect(session);
const page = (await browser.pages())[0];

await page.goto('http://localhost:3000'); // This works!

If you set tunnel: true without a tunnelName, the SDK auto-generates a name and starts the tunnel for you.

Manual Tunnel

For more control - for example, starting the tunnel once and reusing it across multiple sessions:

// Start the tunnel
await client.tunnel.start({
user: process.env.LT_USERNAME!,
key: process.env.LT_ACCESS_KEY!,
tunnelName: 'my-tunnel',
});

console.log('Tunnel running:', client.tunnel.getStatus()); // true

// Create sessions that use it
const session = await client.sessions.create({
adapter: 'puppeteer',
tunnel: true,
tunnelName: 'my-tunnel',
lambdatestOptions: { ... }
});

// ... agent work ...

// Stop when done
await client.tunnel.stop();

Tunnel Config

interface TunnelConfig {
user: string; // TestMu AI username
key: string; // TestMu AI access key
tunnelName?: string; // Named tunnel for identification
proxyHost?: string; // Corporate proxy host
proxyPort?: string; // Corporate proxy port
proxyUser?: string; // Proxy auth user
proxyPass?: string; // Proxy auth password
logFile?: string; // Log file path
}

API

await client.tunnel.start(config);   // Start tunnel
await client.tunnel.stop(); // Stop tunnel
client.tunnel.getStatus(); // Returns true/false

How It Works

The Tunnel Service uses the @lambdatest/node-tunnel package to create a binary tunnel connection to TestMu AI infrastructure. The tunnel name is passed as a TestMu AI capability so cloud browsers know to route their traffic through your local machine.

Test across 3000+ combinations of browsers, real devices & OS.

Book Demo

Help and Support

Related Articles