Search code examples
ios.net-corebrowserstack

Cannot load site on localhost with iOS devices on BrowserStack Automate


I'm hosting a .NET Core HTTP application on localhost using Kestrel on an available port for some browser-based UI tests, but when trying to access it using real iOS devices with BrowserStack Automate with BrowserStackLocal.exe, Safari consistently refuses load the page.

I've tried various parts of the IP ranges documented here, but none have been successful. Desktop browsers (Chrome, IE, Edge and Firefox on Windows, Safari on macOS Mojave) and real Android devices work as expected.

I've also tried using the local IP address of the machine and the fully-qualified domain name (FQDN) as described here, but neither work portably as Windows Firewall blocks the connections even through BrowserStack Automate can resolve the address.

Port 80 is not a viable solution as developers' machines will have IIS running on their machines using that port, so it is not available for other purposes.

Given the following constraints, what are the workable solutions?

  1. Hosted on HTTP.
  2. Runs without admin privileges (i.e. no reconfiguring the firewall or using privileged port numbers <1024).
  3. At least two possible port numbers to use so that if one is in use there's at least one alternate to try.
  4. No additional manual setup required to run the tests (should just be the command dotnet test).

Solution

  • On the iOS devices, try resolving http://bs-local.com:5000 instead of http://localhost:5000.