Skip to main content
Transform your testing process with: Real Device Features, Company-wide Licences, & App Percy

Manage Incoming Connections

The guide to managing the incoming connections from localhost servers or private servers.

Test apps that retrieve data from localhost servers

Once you’ve enabled Local Testing, our remote devices will be able to access apps that retrieve data from your localhost servers. Use the capability in your test scripts to access and interact with your apps:

If you are using BrowserStack SDK, you can set the capabilities covered in this document within the browserstack.yml file:

browserstack.yml
Copy icon Copy snippet

Test apps that retrieve data from private or internal servers

You can securely test mobile apps that retrieve data from private or internal servers using --force-local on our remote mobile devices. This option resolves all requests (on our remote devices) through your local machine.

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

browserstack.yml
Copy icon Copy snippet

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).

BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page.

DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
browserstackOptions.put("local", "true");
var capabilities = {
	'bstack:options' : {
		"local" : "true",
	},
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
browserstackOptions.Add("local", "true");
$caps = array(
    'bstack:options' => array(
        "local" => "true",
    ),
)
desired_cap = {
	'bstack:options' : {
		"local" : "true",
	},
}
capabilities = {
    'bstack:options' => {
        "local" => "true",
    },
}
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability("browserstack.local", "true");
var capabilities = {
	'browserstack.local': 'true',
}
DesiredCapabilities capability = new DesiredCapabilities();
capability.SetCapability("browserstack.local", "true");
$capabilities = new DesiredCapabilities();
$capabilities->setCapability("forcelocal", "true");
desired_cap = {
	'browserstack.local': 'true'
}
desired_caps = {
    'browserstack.local': 'true'
}

Test apps that retrieve data from private or internal servers

You can securely test mobile apps that retrieve data from private or internal servers using --force-local on our remote mobile devices. This option resolves all requests (on our remote devices) through your local machine.

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

Add the following snippet to your test scripts for bs_local_args:

bs_local_args = { "key" => "YOUR_ACCESS_KEY" , "forcelocal" => "true"}
bsLocalArgs.put("forcelocal", "true");
bs_local_args = { "key": "YOUR_ACCESS_KEY" , "forcelocal": "true"}
bs_local_args = { 'key': 'YOUR_ACCESS_KEY', 'forceLocal': 'true' }
bsLocalArgs.Add(new KeyValuePair("forcelocal", "true"));
$bs_local_args = array("key" => "YOUR_ACCESS_KEY", "forcelocal" => true);

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).

Test apps that retrieve data from servers behind a firewall and/or VPNs

With Local Testing, you can test apps that retrieve data/assets from internal servers that are behind firewalls and/or VPNs.

Start by making sure that you can access the app on your machine. Then, set up a Local Testing connection by following the steps listed in Test apps that retrieve data from private or internal servers.

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:

Steps Details
Language bindings Write the code to start the local binary before accessing mobile apps that retrieve content from your local or staging servers. Close the connection after the test execution is complete.
CI server Write a script that will establish the Local Testing connection before running a test. Close the connection after the test execution is complete.
Binary Run the Local binary using a command-line interface with appropriate flags before triggering your tests. Close the connection after the 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

Is this page helping you?

Yes
No

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!

Talk to an Expert
Download Copy