Test websites hosted behind proxies
Start testing locally hosted websites that are behind one or more proxies
This page is applicable if the website under test is behind a proxy. For e.g. if your website is hosted on https://localhost:3000
or any other similar private URL.
If your test scripts will be run from a system that is also behind the same/different proxy, then please follow the running Selenium test from behind proxy documentation
If you have correctly set up Local Testing but are still unable to load your local/internally-hosted website/assets on BrowserStack, then you might be behind a proxy.
You can use Local Testing to test websites hosted behind proxies, on our remote browsers and devices. The setup will vary based on the proxy implementation in your network. Currently, we only support Local Testing through the following proxies:
- Proxy with no authentication or HTTP Basic Authentication.
- MITM proxy with no authentication or HTTP Basic Authentication.
- PAC (Proxy Auto-Configuration) with no authentication.
For Local Testing to work correctly, bypass traffic for bs-local.com
in your proxy server.
Proxy
Proxies are commonly set up for office networks, remote servers, and sometimes on local machines. Contact your network/IT team to obtain the ‘Proxy Host’ and ‘Proxy Port’ to setup Local Testing for this implementation.
Once you obtain the Host and Port, you can establish a Local Testing connection using one of following ways:
If you are using the BrowserStack SDK, add the following snippet to your browserstack.yml
file:
If your proxy requires authentication, use the following code snippet:
MITM Proxy
If your proxy type is MITM (like BrowserMob), you will need the ‘Proxy Host’ and ‘Proxy Port’. Once you have the Host and Port, you can establish a Local Testing connection by performing the following steps:
Add the following snippet to your browserstack.yml
file:
If your proxy requires authentication, use the following code snippet:
Add the following snippet to your test scripts:
bsLocalArgs.put("proxyHost", "127.0.0.1");
bsLocalArgs.put("proxyPort", "8000");
bs_local_args = { 'key': '<browserstack-accesskey>', 'proxyHost': '127.0.0.1', 'proxyPort': '8000' }
bsLocalArgs.Add(new KeyValuePair<string, string>("proxyHost", "127.0.0.1"));
bsLocalArgs.Add(new KeyValuePair<string, string>("proxyPort", "8000"));
$bs_local_args = array("key" => "<browserstack-accesskey>", "proxyHost" => "127.0.0.1", "proxyPort" => "8000");
bs_local_args = { "key": "<browserstack-accesskey>", "proxyHost": "127.0.0.1", "proxyPort": "8000"}
bs_local_args = { "key" => "<browserstack-accesskey>", "proxyHost" => "127.0.0.1", "proxyPort" => "8000"}
my %bs_local_args = ("key" => "<browserstack-accesskey>", "proxyHost" => "127.0.0.1", "proxyPort" => "8000"");
If your proxy requires authentication, use the following code snippet:
bsLocalArgs.put("proxyHost", "127.0.0.1");
bsLocalArgs.put("proxyPort", "8000");
bsLocalArgs.put("proxyUser", "user");
bsLocalArgs.put("proxyPass", "password");
bs_local_args = { 'key': '<browserstack-accesskey>', 'proxyHost': '127.0.0.1', 'proxyPort': '8000', 'proxyUser': 'user', 'proxyPass': 'password' }
bsLocalArgs.Add(new KeyValuePair<string, string>("proxyHost", "127.0.0.1"));
bsLocalArgs.Add(new KeyValuePair<string, string>("proxyPort", "8000"));
bsLocalArgs.Add(new KeyValuePair<string, string>("proxyUser", "user"));
bsLocalArgs.Add(new KeyValuePair<string, string>("proxyPass", "password"));
$bs_local_args = array("key" => "<browserstack-accesskey>", "proxyHost" => "127.0.0.1", "proxyPort" => "8000", "proxyUser" => "user", "proxyPass" => "password");
bs_local_args = { "key": "<browserstack-accesskey>", "proxyHost": "127.0.0.1", "proxyPort": "8000", "proxyUser": "user", "proxyPass": "password"}
bs_local_args = { "key" => "<browserstack-accesskey>", "proxyHost" => "127.0.0.1", "proxyPort" => "8000", "proxyUser" => "user", "proxyPass" => "password"}
my %bs_local_args = ("key" => "<browserstack-accesskey>", "proxyHost" => "127.0.0.1", "proxyPort" => "8000", "proxyUser" => "user", "proxyPass" => "password");
MITM Proxy
If your proxy type is MITM (like BrowserMob), you will need the ‘Proxy Host’ and ‘Proxy Port’. Once you have the Host and Port, you can establish a Local Testing connection by performing the following steps:
Add the following snippet to your test scripts:
bsLocalArgs.put("localProxyHost", "127.0.0.1");
bsLocalArgs.put("localProxyPort", "8000");
bs_local_args = { 'key': '<browserstack-accesskey>', 'localProxyHost': '127.0.0.1', 'localProxyPort': '8000' }
bsLocalArgs.Add(new KeyValuePair<string, string>("localProxyHost", "127.0.0.1"));
bsLocalArgs.Add(new KeyValuePair<string, string>("localProxyPort", "8000"));
$bs_local_args = array("key" => "<browserstack-accesskey>", "localProxyHost" => "127.0.0.1", "localProxyPort" => "8000");
bs_local_args = { "key": "<browserstack-accesskey>", "localProxyHost": "127.0.0.1", "localProxyPort": "8000"}
bs_local_args = { "key" => "<browserstack-accesskey>", "localProxyHost" => "127.0.0.1", "localProxyPort" => "8000"}
my %bs_local_args = ("key" => "<browserstack-accesskey>", "localProxyHost" => "127.0.0.1", "localProxyPort" => "8000"");
If your proxy requires authentication, use the following code snippet:
bsLocalArgs.put("localProxyHost", "127.0.0.1");
bsLocalArgs.put("localProxyPort", "8000");
bsLocalArgs.put("-localProxyUser", "user");
bsLocalArgs.put("-localProxyPass", "password");
bs_local_args = { 'key': '<browserstack-accesskey>', 'localProxyHost': '127.0.0.1', 'localProxyPort': '8000', 'localProxyUser': 'user', 'localProxyPass': 'password' }
bsLocalArgs.Add(new KeyValuePair<string, string>("localProxyHost", "127.0.0.1"));
bsLocalArgs.Add(new KeyValuePair<string, string>("localProxyPort", "8000"));
bsLocalArgs.Add(new KeyValuePair<string, string>("-localProxyUser", "user"));
bsLocalArgs.Add(new KeyValuePair<string, string>("-localProxyPass", "password"));
$bs_local_args = array("key" => "<browserstack-accesskey>", "localProxyHost" => "127.0.0.1", "localProxyPort" => "8000", "-localProxyUser" => "user", "-localProxyPass" => "password");
bs_local_args = { "key": "<browserstack-accesskey>", "localProxyHost": "127.0.0.1", "localProxyPort": "8000", "-localProxyUser": "user", "-localProxyPass": "password"}
bs_local_args = { "key" => "<browserstack-accesskey>", "localProxyHost" => "127.0.0.1", "localProxyPort" => "8000", "-localProxyUser" => "user", "-localProxyPass" => "password"}
my %bs_local_args = ("key" => "<browserstack-accesskey>", "proxyHost" => "127.0.0.1", "localProxyPort" => "8000", "-localProxyUser" => "user", "-localProxyPass" => "password");
If you prefer using BrowserStack CLI, use the following method:
Use the –proxy-host and –proxy-port flags while establishing a Local Testing connection:
Run the binary using the following command:
If your proxy requires authentication, add --proxy-user
and --proxy-pass
to the above command.
Run the binary using the following command:
To resolve all requests on our remote browsers and mobile devices through your proxy, add --force-proxy
and --force-local
flags to the command. Without these flags, Local binary tries to connect directly for better performance.
MITM Proxy
If your proxy type is MITM (like BrowserMob), you will need the ‘Proxy Host’ and ‘Proxy Port’. Once you have the Host and Port, you can establish a Local Testing connection by performing the following steps:
Use the following command to establish the Local Testing connection:
Run the binary using the following command:
If your local proxy requires authentication, add --local-proxy-user
and --local-proxy-pass
to the above command.
To resolve all requests on our remote browsers and mobile devices through your local proxy, add --force-proxy
and --force-local
flags to the command. Without these flags, Local binary tries to connect directly for enhanced performance.
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
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!