You may have noticed an issue when using Sauce Connect Proxy with not being able to connect to your web applications at localhost when using certain ports. For example:
- Spin up a local server serving content on port
9998
. - Start Sauce Connect Proxy.
- Open a Sauce Session in Safari 8 or 9, or Edge, and try to load
localhost:9998
.
You won't be able to access the content. - Start another local server on port
3000
. - Open
localhost:3000
in the same session
You will be able to access the content.
This will happen with Safari 8 and 9, and Edge browsers. The issue is these browsers will never send localhost URLs via a proxy, and always use a non-proxied connection to reach localhost.
You have two options for a workaround.
- Modify the hosts file in the machine running Sauce Connect Proxy. Just add a fake domain, such as
myname.local
, that points to127.0.0.1
. Then, point your tests to that URL instead oflocalhost
. This will skip the localhost proxy entirely and prevent the issue, and may even improve the performance of your tests.
- Use the Sauce Connect localhost proxy to connect over a different port. The answer to the question "Can I Access Applications on localhost" in the Sauce Connect Proxy FAQs contains a list of all the ports you can use with Safari.