Manage Incoming Connections

Test localhost websites

Once you’ve enabled Local Testing connection, our remote browsers and mobile devices will be able to access localhost URLs.

Use your test scripts to access and interact with your localhost website (for example, localhost:3000). Remember to set browserstack.local capability to true in your test scripts.

Note: Due to security restrictions in Safari (on iOS 10 and above), localhost URLs will automatically change to http://bs-local.com. This lets us load your website assets properly and does not affect your test scripts. Remember to configure your local server to serve requests from bs-local.com.

Test websites hosted on private or internal servers

You can securely test websites hosted on private or internal servers with Local Testing using --force-local capability. This option resolves all requests (on our remote browsers and devices) through your local machine.

To enable this option, use one of two ways to establish the Local Testing connection:

Via language bindings

Add the following snippet to your test scripts:

bsLocalArgs.put("forcelocal", "true");
bs_local_args = { 'key': '<browserstack-accesskey>', 'forceLocal': 'true' }
bsLocalArgs.Add(new KeyValuePair<string, string>("forcelocal", "true"));
$bs_local_args = array("key" => "<browserstack-accesskey>", "forcelocal" => true);
bs_local_args = { "key": "<browserstack-accesskey>" , "forcelocal": "true"}
bs_local_args = { "key" => "<browserstack-accesskey>" , "forcelocal" => "true"}
my %bs_local_args = ("key" => "<browserstack-accesskey>", "forcelocal" => "true");

Via command-line interface

Use the --force-local flag while establishing a Local Testing connection.

./BrowserStackLocal --key YOUR_ACCESS_KEY --force-local
BrowserStackLocal.exe --key YOUR_ACCESS_KEY --force-local

After establishing the Local Testing connection, use your test scripts to access and interact with your internally-hosted website (for example, staging.example.com). Remember to set browserstack.local capability to true in your test scripts.

Test local HTTPS websites

You can test local websites with SSL certificates on our remote browsers and devices through Local Testing.

When you access local websites that have SSL certificates on the browsers, you might see an “invalid certificate” error:

manage incoming connections

To avoid invalid certificate errors while testing on our remote browsers, set the acceptSslCerts capability to true in your test scripts.

caps.setCapability("acceptSslCerts", "true");
var capabilities = {
  'acceptSslCerts' : 'true'
}
caps.SetCapability("acceptSslCerts", "true");
$caps['acceptSslCerts'] = "true";
caps['acceptSslCerts'] = True
caps['acceptSslCerts'] = 'true'
$caps->{"acceptSslCerts"} = "true";

Now, use your test scripts to access and interact with your local HTTPS websites (for example, https://localhost:3000 or https://staging.example.com). Remember to set browserstack.local capability to true in your test scripts before you run them.

Connection duration and disconnection

The Local Testing connection is persistent. Your machine and BrowserStack Cloud remain connected unless you explicitly end the connection.

In the following scenarios, ensure that you open and close the connection by following the steps:

Language bindings: Write the code to start the Local binary before accessing websites on your internal servers. Close the connection after test execution is complete.

CI server: Write a script that will establish the Local Testing connection before running a test. Close the connection after test execution is complete.

Binary: Run the Local binary using command-line interface with appropriate flags before triggering your tests. Close the connection after test execution is complete.

We're sorry to hear that. Please share your feedback so we can do better






Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback