The Sauce Labs Cookbook

Sauce Headless

Front End Performance Testing


External Resources

More Info

Page tree
Skip to end of metadata
Go to start of metadata

Every Sauce Connect tunnel spins up a fresh virtual machine (VM) that is used only for your tests. Once the tunnel is closed, VMs are destroyed. As a best practice, we recommend you create a new tunnel for each test suite or build and tear it down at the end of your test. 

Starting New Sauce Connect Tunnels

Start a New Tunnel via Command-Line

You can launch a new tunnel from the command line of the machine where the Sauce Connect Proxy client is installed by copying the Run Command, which will include your authentication credentials. You can also add any Sauce Connect Proxy parameters you want to use in configuring your tunnel. 

See Basic Sauce Connect Proxy Setup for full instructions on launching tunnels.

Stopping Sauce Connect Tunnels (also known as Teardown Process)

Stop an Individual Tunnel via Command-Line

Once Sauce Connect has been terminated (typically via ctrl-c), a call will be made from Sauce Connect to the REST API with instructions to terminate the Tunnel VM. Sauce Connect will continue to poll the REST API until the Tunnel VM has been halted and deleted. 

NOTE: If you are using the Sauce Connect High Availability Configuration and attempt to terminate a running test with ctrl-c, you will see a message that Sauce Connect will not terminate until tests have completed. If you want to force Sauce Connect to terminate before the test finishes, enter ctrl-c again to force it to quit.

Stop an Individual Tunnel from the User Interface

From the Tunnels page of Sauce Labs, click Stop under the Actions column in the tunnel information table.

Stop All Tunnels in Your Account from the User Interface

From Tunnels page of Sauce Labs, click Stop My Tunnels in the top-right corner of the page.

Stop an Individual Tunnel via the Command Line

To stop an individual tunnel via the command line/prompt, you must send some sort of KILL signal to the running Process ID (pid).

  1. Start the Sauce Connect process

  2. Fetch and Save the process IDs for later use:

    $ ps aux | grep bin/sc


    $SAUCE_USERNAME   38312   0.1  0.1  4461780  20084 s000  S+    2:58PM   0:00.33 sc-<VERSION>-<PLATFORM>/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY
  3. Send some sort of KILL signal to each Process ID (pid)

    $ kill -2 38312

    NOTE: Windows has no "signals" command the way Linux/Unix/MacOS does, instead they use TaskKill iirc, for example: taskill /PID 1234

Stopping Multiple Tunnels via the Command Line

Before you attempt to stop/teardown all your running tunnels, please understand the following workflow:

Here is an example using Linux commands:

  • ps aux | grep sc: Lists matching process(es), 
  • | grep -v grep : Filters out the grep process itself,
  • | awk '{print $2}': Grabs the pid
  • | xargs kill -9: Passes it to kill -9.

NOTE:  xargs kill -9 will immediately disrupt all jobs currently running through that tunnel.  If you wish to interrupt the program in order to gracefully shutdown the tunnels use the xargs kill -2 signal instead. Sauce Labs recommends first trying this command without xargs kill -9 to ensure you don't unnecessarily delete adjacent running processes.

Read the kill command manual to find out more information about acceptable signals and parameters.

Example Linux command of killing all running tunnels
$ ps aux | grep sc | grep -v grep | awk  '{print $2}' | xargs kill -9

More Information