---
title: Configuring Appium tests with Proxy | TestingBot
description: Route all HTTP and HTTPS traffic from an iOS or Android device through
  a proxy during your Appium tests on TestingBot. Useful for traffic inspection, HAR
  capture and mocking.
source_url:
  html: https://testingbot.com/support/app-automate/appium/proxy
  md: https://testingbot.com/support/app-automate/appium/proxy/index.md
---
# Configure a device with a proxy

You can use Appium or Selenium WebDriver to configure a proxy on the remote Android or iOS device, at the start of your test.

This makes sure that all traffic on the device will go through the external proxy, which can be useful to do [geolocation testing](https://testingbot.com/support/app-automate/appium/options#geo) or latency testing.

[Ruby](https://testingbot.com#)[Python](https://testingbot.com#)[PHP](https://testingbot.com#)[Java](https://testingbot.com#)[NodeJS](https://testingbot.com#)[C#](https://testingbot.com#)

    desired_caps = {
      'platformName' => 'Android',
      'appium:deviceName' => 'Pixel 9',
      'appium:platformVersion' => '16.0',
      'appium:app' => 'https://testingbot.com/appium/sample.apk',
      'tb:options' => {
        'realDevice' => true
      }
    }
    
    # Set up the proxy settings
    proxy = {
      'proxyType' => 'manual', # Proxy type (manual or system)
      'httpProxy' => 'http://your-proxy-server:8080', # Replace with your HTTP proxy URL
      'sslProxy' => 'http://your-proxy-server:8080', # Replace with your SSL proxy URL
      'noProxy' => 'localhost,127.0.0.1' # Optional: bypass proxy for specific hosts
    }
    
    # Add proxy to desired capabilities
    desired_caps['proxy'] = proxy
    
    # Initialize the Appium driver
    driver = Appium::Driver.new({
      caps: desired_caps,
      appium_lib: { server_url: 'https://API_KEY:API_SECRET@hub.testingbot.com/wd/hub' }
    }, true)

    UiAutomator2Options options = new UiAutomator2Options();
    
    // Set basic capabilities
    options.setPlatformName("Android");
    options.setCapability("appium:deviceName", "Pixel 9");
    options.setCapability("appium:platformVersion", "16.0");
    options.setCapability("appium:app", "https://testingbot.com/appium/sample.apk");
    
    // Set TestingBot-specific options
    Map<String, Object> tbOptions = new HashMap<>();
    tbOptions.put("realDevice", true);
    options.setCapability("tb:options", tbOptions);
    
    // Set up proxy settings
    Proxy proxy = new Proxy();
    proxy.setHttpProxy("http://your-proxy-server:8080"); // Replace with your HTTP proxy URL
    proxy.setSslProxy("http://your-proxy-server:8080"); // Replace with your SSL proxy URL
    
    // Apply the proxy settings to the capabilities
    options.setProxy(proxy);
    
    // Initialize the driver with TestingBot Appium server URL
    URL appiumServerUrl = new URL("https://hub.testingbot.com/wd/hub");
    AndroidDriver driver = new AndroidDriver(appiumServerUrl, options);

    $capabilities = array(
        'platformName' => 'Android',
        'appium:app' => 'https://testingbot.com/appium/sample.apk',
        'appium:deviceName' => 'Pixel 9',
        'appium:platformVersion' => '16.0',
        'tb:options' => array(
            'realDevice' => true
        ),
        'proxy' => array(
            'proxyType' => 'manual', // Proxy type, "manual" for custom proxy settings
            'httpProxy' => 'http://your-proxy-server:8080', // Replace with your HTTP proxy
            'sslProxy' => 'http://your-proxy-server:8080', // Replace with your SSL proxy (HTTPS traffic)
            'noProxy' => 'localhost,127.0.0.1' // Optional: addresses that should bypass the proxy
        )
    );
    // Pass HTTP proxy host/port as the 5th/6th args to RemoteWebDriver::create()
    $web_driver = RemoteWebDriver::create('https://hub.testingbot.com/wd/hub', $capabilities, null, null, 'your-proxy-server', 8080);

    capabilities = {
        "platformName": "Android",
        "appium:deviceName": "Pixel 9",
        "appium:platformVersion": "16.0",
        "appium:app": "https://testingbot.com/appium/sample.apk",
        "tb:options": {
            "realDevice": True
        },
        "proxy": {
            "proxyType": "manual", # Or "system" if you want to use system proxy
            "httpProxy": "http://your-proxy-server:8080", # Replace with your proxy server
            "sslProxy": "http://your-proxy-server:8080", # Replace with your proxy server for SSL
            "noProxy": "localhost,127.0.0.1" # Optional: specify addresses to bypass the proxy
        }
    }
    
    from appium.options.android import UiAutomator2Options
    
    options = UiAutomator2Options().load_capabilities(capabilities)
    driver = webdriver.Remote(
        command_executor="https://hub.testingbot.com/wd/hub",
        options=options
    )

    const { remote } = require('webdriverio');
    
    const capabilities = {
      hostname: 'hub.testingbot.com',
      port: 443,
      protocol: 'https',
      path: '/wd/hub',
      user: 'api_key',
      key: 'api_secret',
      capabilities: {
        'platformName': 'Android',
        'appium:deviceName': 'Pixel 9',
        'appium:platformVersion': '16.0',
        'appium:app': 'https://testingbot.com/appium/sample.apk',
        'tb:options': {
          'name': 'My First App Test',
          'realDevice': true
        },
        'proxy': {
          proxyType: 'manual',
          httpProxy: 'http://proxy-server:8080', // Replace with your proxy server URL
          sslProxy: 'http://proxy-server:8080', // If needed for SSL connections
          noProxy: '' // You can define URLs to bypass the proxy
        }
      }
    };
    
    const driver = await remote(capabilities);

    AppiumOptions options = new AppiumOptions();
    options.PlatformName = "Android";
    options.AddAdditionalAppiumOption("appium:deviceName", "Pixel 9");
    options.AddAdditionalAppiumOption("appium:platformVersion", "16.0");
    options.AddAdditionalAppiumOption("appium:app", "https://testingbot.com/appium/sample.apk");
    
    // Set TestingBot-specific options
    var tbOptions = new Dictionary<string, object>
    {
        ["realDevice"] = true
    };
    options.AddAdditionalAppiumOption("tb:options", tbOptions);
    
    // Set up proxy using the Proxy class
    Proxy proxy = new Proxy();
    proxy.HttpProxy = "http://your-proxy-server:8080"; // Replace with your proxy URL
    proxy.SslProxy = "http://your-proxy-server:8080"; // Replace with your proxy URL
    proxy.NoProxy = "localhost,127.0.0.1"; // Optional: bypass proxy for specific addresses
    
    // Apply the proxy to the Appium options
    options.Proxy = proxy;
    
    // Initialize the driver
    AndroidDriver driver = new AndroidDriver(new Uri("https://hub.testingbot.com/wd/hub"), options);

Was this page helpful? Yes No 

## Looking for More Help?

Have questions or need more information?   
 You can reach us via the following channels:

- [Email us](https://testingbot.com/contact/new)
- [Join our Slack Channel](https://join.slack.com/t/testingb0t/shared_invite/zt-3bcw9xch-jk19~6XPs_xBrsAgAedkCw)
