Proxying in Mobile QA: Emulator, Real Device, and adb reverse — A Step-by-Step Guide
Table of contents
- Introduction: why a tester needs their own proxy between the app and the server
- Preparation: tools, access, and system requirements
- Core concepts: how traffic interception works
- Step 1: set up an intercepting proxy on your computer
- Step 2: route android emulator traffic through the proxy
- Step 3: install the proxy certificate and solve the trust issue
- Step 4: connect a real device over wi-fi
- Step 5: port forwarding via adb reverse — proxy over usb without wi-fi
- Step 6: intercept and modify test environment traffic
- Result check: final checklist
- Common mistakes and solutions
- Additional capabilities for advanced testers
- Faq: common questions about proxy setup in mobile testing
- Conclusion
Introduction: Why a Tester Needs Their Own Proxy Between the App and the Server
Imagine: you're testing a mobile app, you tap a button, and the screen shows an abstract error "Something went wrong." The developer asks: "What request was sent? What response came back? What was the status code?" Without a proxy, you're shrugging. With a proxy, you open the list of requests, copy the server response body, and attach it to the bug in thirty seconds. That's the difference between a tester who "clicks" and a tester who understands what's happening under the hood.
This article is deliberately different from instructions for regular users, which explain how to enter a proxy address in your phone's Wi-Fi settings. Here we cover the QA engineer's workflow: an intercepting proxy on your computer, routing Android emulator traffic into it, connecting a real device over Wi-Fi and over USB via port forwarding with the adb reverse command, plus intercepting and modifying test environment traffic. The user-level proxy setup on the phone is just one small brick in this process.
What You'll Get by the End
- A working intercepting proxy (mitmproxy or Charles) that shows every HTTP and HTTPS request your app makes.
- An Android emulator whose traffic goes through that proxy, including encrypted traffic.
- A real smartphone connected to the proxy in two ways: over Wi-Fi and over USB cable via adb reverse.
- An understanding of why the app "doesn't trust" the certificate and how to fix that on a test build.
- The skill to modify test environment responses, emulate slow networks and server errors without bothering the backend developer.
Who This Guide Is For
For manual and automation testers of mobile apps who want to see network traffic rather than guess. For juniors whose new job said "check Charles" without explaining what it is or how. For developers who set up the test environment for their team.
What You Should Already Know
A basic understanding of what an HTTP request, response, status code 200 and 500 are. Ability to open a terminal or command prompt and run a command. Experience installing apps on Android. If you've never launched an emulator, don't worry — we'll walk through it together.
How Long It Will Take
With a good internet connection and Android Studio already installed — an hour and a half to two hours for the whole guide. If you don't have Android Studio yet, add 30-60 minutes for downloading system images. After the first run-through, setting up again on a new project takes about ten minutes.
Preparation: Tools, Access, and System Requirements
What to Install on Your Computer
- Android Studio — the current 2025-2026 version. It installs Android SDK, Android Emulator, and the adb utility. This is your core toolkit.
- An intercepting proxy. The guide shows two options: the free mitmproxy (runs in the terminal and via the mitmweb web interface) and the commercial Charles Proxy with a free trial. Pick one; you can learn the other later. Instructions are given for both.
- Java isn't needed separately: Android Studio uses a built-in JDK.
- A test build of the app as an APK. It should be a debug build or a special QA build, not a store release. Why this is critical — we'll explain in the certificates section.
System Requirements
- OS: Windows 10 or 11 (64-bit), macOS 12 or newer, Linux with KVM support.
- RAM: minimum 8 GB, comfortable is 16 GB. The emulator alone eats 2-4 GB.
- Free disk space: at least 20 GB. A single Android system image weighs 1.5-2 GB, plus Android Studio itself.
- Hardware virtualization enabled in BIOS/UEFI (Intel VT-x or AMD-V). Without it, the emulator will be painfully slow or won't start at all.
- A real Android device running Android 8 or higher and a USB cable for data transfer (not just charging).
Access to Request from Your Team
- The test environment address (e.g., https://api-stage.example-team.com) and test credentials.
- A debug build of the app or a "QA build". Ask the developers whether it trusts user certificates and whether certificate pinning is disabled.
- If the environment is IP-restricted or requires connecting to a corporate network — ask your admin how to connect to it from your work computer. We don't cover any ways to bypass restrictions: only the proper access granted by your team.
Backups and Security
Proxy settings on the emulator and device are fully reversible. However, before you start, do two things. First, if the real phone already has working Wi-Fi settings or certificates, take screenshots of the settings screens — that way you can quickly restore everything as it was. Second, it's better to use a dedicated test device rather than your personal phone with banking apps: the proxy's root certificate gives its owner the ability to read encrypted traffic. On a test device that's normal; on a personal one it's a risk.
Warning: Never install the intercepting proxy's root certificate on a personal device that has banking or payment apps, and never share the proxy's private key file with colleagues via messengers. The certificate is generated locally on your computer and should stay there.
Core Concepts: How Traffic Interception Works
What an Intercepting Proxy Is
A regular proxy is a middleman that receives a request from a client and forwards it to a server. An intercepting proxy (also called a debugging or man-in-the-middle proxy) does the same, but also saves a copy of every request and response, shows them to you in a convenient view, and lets you pause, modify, and substitute them. For a tester, it's like an X-ray for a doctor.
Why HTTPS Isn't Visible by Default
Almost all modern traffic is encrypted with TLS. The proxy sees that the phone connected to api-stage.example-team.com, but the contents of requests are an encrypted stream to it. To decrypt, the proxy generates its own root certificate (CA) and on the fly issues fake certificates for each site. The phone must trust this root certificate — otherwise the app will see the substitution and break the connection with an error like "Trust anchor for certification path not found." That's why installing the proxy certificate on the device is a mandatory step.
User vs. System Certificates in Android
Starting with Android 7, apps by default trust only system certificates and ignore those installed by the user through settings. Chrome is the exception; it trusts user certificates. For your app to trust the proxy certificate, developers have two legitimate paths: either add a network_security_config.xml file in the debug build that allows trusting user certificates, or you install the certificate as a system one on a rooted emulator. The first path is simpler and more correct for teamwork.
Certificate Pinning
Some apps additionally "pin" a specific server certificate and refuse to work with any other, even a trusted one. This is good protection in production, but for testing on the environment, pinning is usually disabled in debug builds. If after all the setup the app still doesn't go through the proxy, ask the developers specifically about pinning.
How the Emulator Sees Your Computer
The Android emulator is a virtual machine with its own network. Inside it, the address 127.0.0.1 means the emulator itself, not your computer. To reach the computer from the emulator, a special address 10.0.2.2 is used. Remember it — it will appear in the commands below.
What adb and adb reverse Are
adb (Android Debug Bridge) is a command-line utility that controls an Android device from your computer: it installs apps, runs commands, forwards ports. The adb reverse command makes a port on the device "look at" a port on your computer. For example, after adb reverse tcp:8080 tcp:8080, an app on the phone accessing localhost:8080 will actually hit port 8080 on your computer where the proxy listens. This works over USB, doesn't require a shared Wi-Fi network, and doesn't depend on corporate access point restrictions. The reverse command, adb forward, works the other way: a computer port leads to the device. Don't confuse them.
Test Environment
The environment (stage, staging, dev environment) is a copy of the app's backend for testing. On the test environment you can break data, modify responses, and look at logs. The app usually switches to the environment either via a separate build or a hidden menu. We do all traffic interception with the test environment, not production.
Step 1: Set Up an Intercepting Proxy on Your Computer
Goal of this step: the proxy is running on your computer, listening on a port (8080 for mitmproxy or 8888 for Charles), and you know the computer's IP address on the local network.
Option A: mitmproxy
- Download the mitmproxy installer for your OS from the project's official site or install it via a package manager. On macOS it's convenient via Homebrew, on Windows an .msi installer, on Linux via pipx or a binary archive.
- Open a terminal (on Windows — PowerShell or Windows Terminal).
- Launch the web version with the command:
Lines about starting the proxy on port 8080 will appear in the terminal, and a browser tab will open with the web interface at 127.0.0.1:8081. This is where requests will appear.mitmweb --listen-port 8080 - Note: the mitmweb interface runs on port 8081 while the proxy itself listens on 8080. In device settings you always specify 8080.
- On first launch, mitmproxy creates a .mitmproxy folder in your home directory. It contains mitmproxy-ca-cert.cer — that's the root certificate we'll install on devices later.
Tip: If you want to work entirely in the terminal without a browser, run the mitmproxy command instead of mitmweb. The interface will be console-based: arrows to navigate, Enter to open a request, q to go back. For automation there's mitmdump, which writes the stream to a file.
Option B: Charles Proxy
- Download Charles from the official site, install and launch it. The main window will appear with an empty list on the left and tabs Overview, Contents on the right.
- Open the Proxy → Proxy Settings menu. On the Proxies tab, make sure the port is 8888 and the "Enable transparent HTTP proxying" checkbox is off. Click OK.
- Open Proxy → SSL Proxying Settings. Check Enable SSL Proxying. In the Include block, click Add and add the host * with port 443. This way Charles will decrypt all HTTPS. Later you can narrow the list to the environment's domain.
- If Charles offers to set up a macOS or Windows system proxy, decline: we need the phone's traffic, not the computer's browser. You can disable it later via the Proxy menu by unchecking macOS Proxy or Windows Proxy.
Find Your Computer's IP Address
For a real device over Wi-Fi, you'll need your computer's address on the local network.
- Windows: in PowerShell run ipconfig and find the IPv4 address line on the active Wi-Fi or Ethernet adapter. Usually something like 192.168.1.45.
- macOS: System Settings → Network → select the active connection, the address is shown in details. Or in the terminal: ipconfig getifaddr en0.
- Linux: the command ip addr show or hostname -I.
Write down this address. Below we'll refer to it as 192.168.1.45; substitute your own.
Open the Port in the Firewall
On the first launch, Windows will ask whether to allow mitmproxy or Charles to accept connections. Be sure to allow it for private networks. If the window didn't appear, open "Windows Defender Firewall → Allow an app through firewall" and add the program manually. On macOS permission is asked similarly on the first incoming connection.
Check: Open a browser on your computer, temporarily set its proxy to 127.0.0.1 and port 8080 (or 8888), and visit any site. Request lines should appear in mitmweb or Charles. After checking, remove the proxy from the browser so it doesn't get in the way. An alternative without configuring the browser — the command:
curl -x http://127.0.0.1:8080 -k https://example.comIf a line with example.com appears in the proxy interface, the proxy works.Possible Issues at This Step
- Port is busy. A message like "Address already in use". That means something is already listening on 8080 — often a local environment or another tool. Run the proxy on a different port, e.g. 8082, and use it everywhere below.
- mitmweb doesn't open the browser. Manually open 127.0.0.1:8081. The terminal will print an address with a token; copy it entirely.
- Charles doesn't show HTTPS content, only CONNECT headers. SSL Proxying is not enabled or the host isn't added to Include. Go back to point 3 of option B.
Step 2: Route Android Emulator Traffic Through the Proxy
Goal of this step: the running emulator sends all HTTP and HTTPS requests to your proxy, and you see them in the interface.
Create and Launch the Emulator
- Open Android Studio. If no project is open, on the start screen choose More Actions → Virtual Device Manager. Inside a project: menu Tools → Device Manager.
- Click the create device button (plus or Create Virtual Device).
- Pick a model, e.g. Pixel 8, and click Next.
- Choose a system image. Important: for proxy testing, an image labeled Google APIs is more convenient than Google Play. Google Play images have root access blocked, and you won't be able to install a system certificate if you need one. For Android 14-16, such images are named like "Android 15.0 Google APIs x86_64" (on Apple-silicon computers — arm64-v8a). If there's a download arrow next to the image — download it, this takes 5-15 minutes.
- On the last screen, name the device without spaces, e.g. Pixel_8_QA, and click Finish.
- Launch the emulator with the triangle button. The first launch takes 1-3 minutes.
Method 1: Setup via the Emulator Panel (Easiest)
- In the running emulator window, find the vertical panel on the right. Click the three dots at the bottom — the Extended Controls window opens.
- In the left menu choose Settings, then the Proxy tab.
- Uncheck "Use Android Studio HTTP proxy settings".
- Choose Manual proxy configuration.
- In the Host name field enter 127.0.0.1. Here, unlike in Android's own settings, the emulator applies the proxy at the host-machine level, so the computer's address is specified as 127.0.0.1.
- In the Port number field enter 8080 (for Charles — 8888).
- Click Apply. A status "Proxy status: Success" should appear below. If it says Error — the proxy isn't running or the port is wrong.
Method 2: Setup via adb (Flexible, Good for Scripts)
- Open a terminal. Make sure adb is available: the adb devices command should show a line like emulator-5554 device. If the command isn't found, add the platform-tools folder inside Android SDK to PATH (the path can be found in Android Studio: Settings → Languages and Frameworks → Android SDK).
- Run:
Here we're already "inside" Android, so the computer is designated by the address 10.0.2.2.adb shell settings put global http_proxy 10.0.2.2:8080 - Verify the setting applied:
It should return 10.0.2.2:8080.adb shell settings get global http_proxy - To disable the proxy, run:
adb shell settings put global http_proxy :0
Method 3: Command-Line Parameter at Launch
If you launch the emulator from the terminal (e.g., in CI or scripts), add the flag:
emulator -avd Pixel_8_QA -http-proxy http://127.0.0.1:8080The emulator executable is in the emulator folder inside Android SDK. The proxy will apply to the entire emulator session.
Tip: Make two small scripts — proxy_on and proxy_off — with the adb commands from method 2. During a testing day you'll enable and disable the proxy dozens of times, and extra menu clicks get tiring.
Verify Traffic Is Flowing
- In the emulator open Chrome and visit any HTTPS site.
- Requests should appear in mitmweb or Charles. Most likely the Chrome page will show a security error — that's normal, we haven't installed the certificate yet. The key thing is that requests are visible as records with the host and the CONNECT method.
Check: Lines with the domain of the site you opened in the emulator appear in the proxy interface, and the command adb shell settings get global http_proxy returns your proxy's address and port. If both conditions are met — the emulator is routed to the proxy correctly.
Possible Issues
- Proxy status: Error in the emulator panel. The proxy isn't running, or it's the wrong port. Start mitmweb or Charles and click Apply again.
- Requests don't appear despite Success status. The app may use its own network stack that ignores the system proxy (e.g., Flutter apps by default). See the typical errors section.
- Emulator lost internet after disabling the proxy. You likely left http_proxy empty rather than ":0". Repeat the disable command with a colon and zero and restart the emulator.
Step 3: Install the Proxy Certificate and Solve the Trust Issue
Goal of this step: the emulator and the test app trust the proxy's root certificate, and you see decrypted HTTPS content: URLs, headers, request and response bodies.
Install the Certificate as a User Certificate
- Make sure the proxy is enabled on the emulator (Step 2).
- In Chrome inside the emulator, open mitm.it (for mitmproxy) or chls.pro/ssl (for Charles). These are special addresses that the proxy intercepts and serves a certificate download page for. If you see a regular site or an error instead of the page — traffic isn't going through the proxy, go back to Step 2.
- For mitmproxy click the Android button and download the mitmproxy-ca-cert.cer file. For Charles the file downloads immediately.
- On the emulator open Settings → Security & privacy → More security settings → Encryption & credentials → Install a certificate → CA certificate (on some versions the path is: Security → Additional settings → Encryption & credentials). A warning about risks appears — tap "Install anyway".
- Select the downloaded file in the Downloads folder. If the emulator asks you to set a screen PIN, set a simple one like 1234 and remember it.
- After installation, verify: Encryption & credentials → Trusted credentials → the User tab. An entry for mitmproxy or Charles Proxy CA should appear there.
An alternative without a browser — copy the file with adb push and then select it from a file manager:
adb push ~/.mitmproxy/mitmproxy-ca-cert.cer /sdcard/Download/Now Chrome in the emulator will open any HTTPS site without errors, and you'll see decrypted browser requests in the proxy. But your test app will most likely still fail with a network error. Let's move to the main part.
Why the App Doesn't Trust and What to Ask Developers For
As we covered in the core concepts, apps on Android 7+ ignore user certificates. The right solution is for the debug build to contain a network security config file. The developer adds something like the following to res/xml/network_security_config.xml:
<network-security-config><debug-overrides><trust-anchors><certificates src='system' /><certificates src='user' /></trust-anchors></debug-overrides></network-security-config>And hooks it up in AndroidManifest.xml via the android:networkSecurityConfig attribute. The debug-overrides block works only in debug builds, so the release remains secure. This is standard practice, and most teams already have this file. Copy the snippet above into a task for the developer if it's missing.
Warning: Don't ask to add user certificate trust to the base configuration without debug-overrides, and don't agree to disabling certificate checks in release. That would weaken protection for real users. All changes should affect only debug and QA builds.
Fallback: System Certificate on a Rooted Emulator
If the build can't be changed for you, on a Google APIs emulator (not Google Play) the certificate can be placed in the system store. Then any apps without pinning will trust it. Briefly, the procedure for Android 14 and newer, where system certificates are in the apex partition:
- Launch the emulator from the terminal with the -writable-system flag.
- Run adb root, then adb remount.
- Compute the certificate filename in hash.0 format with the command openssl x509 -inform PEM -subject_hash_old -in mitmproxy-ca-cert.cer -noout and rename the file to the resulting value with the .0 suffix (e.g., c8750f0d.0).
- Copy the file into the system certificate store via adb push to /system/etc/security/cacerts/ and reboot the emulator. On Android 14+ you additionally need to remount the directory where the system loads certificates; mitmproxy's documentation has a ready-made script for this.
This path is more powerful but more fragile: after an image update everything resets, and on Android 14+ the steps are harder. For daily work we recommend the first path with network_security_config.
Install the Test App
- Put the APK in a convenient folder.
- Run adb install -r path/to/app-debug.apk. The -r flag reinstalls over an existing version, preserving data.
- After 10-30 seconds Success appears, and the app icon shows up in the emulator.
Check: Open the test app, log in to the environment. Requests to the environment's domain have appeared in mitmweb or Charles, and clicking any of them shows tabs with headers, the JSON request body, and the response body. If the response body is readable — the certificate is installed and the app trusts it. This is the main checkpoint of the entire guide.
Possible Issues
- Chrome opens sites but the app shows a network error. The app doesn't trust the user certificate. You need a build with network_security_config or a system certificate.
- The app log (adb logcat) shows "Certificate pinning failure". Pinning is enabled. Ask for a QA build with pinning disabled for the environment domain.
- mitm.it shows the page "If you can see this, traffic is not passing through mitmproxy". The proxy didn't apply. Check the Step 2 setup.
Step 4: Connect a Real Device over Wi-Fi
Goal of this step: a real smartphone on the same Wi-Fi network as the computer sends traffic to the proxy.
This is the method described in regular user instructions, but a tester has their own nuances: you need to understand when it won't work and be able to switch quickly. An emulator doesn't replace a real device: it has no real camera, push notifications arrive differently, sensors and power saving behave differently. So testing network scenarios on a real phone is a must.
Set the Proxy in Wi-Fi Settings
- Connect the phone to the same Wi-Fi network as the computer. A home router will do. A corporate guest network often won't — more on that below.
- Open Settings → Network & internet → Wi-Fi (on Samsung: Connections → Wi-Fi).
- Tap the gear next to the current network or long-press the network name to bring up the menu and choose "Modify network".
- Expand "Advanced" or "Advanced settings".
- Under Proxy choose Manual.
- Proxy hostname: your computer's IP address, e.g. 192.168.1.45. Port: 8080 or 8888. Leave the "Bypass proxy for" field empty.
- Save. The phone will reconnect to the network.
Install the Certificate on the Phone
- Open Chrome on the phone and go to mitm.it or chls.pro/ssl. Download the certificate.
- Settings → Security → Encryption & credentials → Install a certificate → CA certificate → select the file. Menu names differ slightly on Samsung, Xiaomi, Huawei, but the logic is the same: look for the words "credentials" or "certificate".
- Install the test app via adb install or directly from the file.
Tip: Give your computer a permanent IP address in the router settings (DHCP reservation by MAC address). Otherwise, after a router reboot the address changes, and every phone on the team stops going through the proxy while you spend half an hour hunting for the cause.
When Wi-Fi Method Doesn't Work
- Client isolation (AP isolation) in a corporate or guest network. Devices see the internet but not each other. Symptom: the phone with proxy loses internet entirely, and mitm.it doesn't open. Test: from the computer, ping the phone's IP address (you can find it in the Wi-Fi properties). No reply — there's isolation.
- Computer and phone on different subnets. For example, the laptop is on a wired network 10.10.0.x and the phone is on Wi-Fi 192.168.1.x.
- Computer firewall blocks incoming. Especially common on Windows with a "Public" network. Switch the network profile to "Private".
In all these cases the solution is the same — port forwarding over USB, which we turn to next.
Check: Requests from the phone have appeared in the proxy interface, and in Charles the Client column shows the phone's IP, different from 127.0.0.1. Open the test app, perform any action — the corresponding request to the environment appeared in the list with a decrypted body.
Step 5: Port Forwarding via adb reverse — Proxy over USB Without Wi-Fi
Goal of this step: a real phone connected only by USB cable routes traffic to the proxy on the computer, regardless of Wi-Fi network.
This is the most reliable method for an office, coworking space, or any network where you don't control the router. The idea: with the adb reverse command, we make port 8080 on the phone itself lead to port 8080 on the computer. Then we tell the phone to use the proxy 127.0.0.1:8080 — that is, "itself" — and adb quietly delivers the packets to the computer.
Enable USB Debugging
- On the phone, open Settings → About phone and tap "Build number" seven times. The message "You are now a developer" appears. On Xiaomi you need to tap "MIUI version" or "HyperOS version".
- Go back to Settings → System → Developer options (on Samsung — at the root of Settings). Turn on the USB debugging toggle.
- Connect the phone to the computer with a cable. The phone shows a prompt "Allow USB debugging?" with the computer's fingerprint. Check "Always allow" and tap Allow.
- On the computer run adb devices. A line with the serial number and the word device should appear. If it says unauthorized — look at the phone screen, the prompt is there. If offline — reconnect the cable.
Warning: Use a cable that supports data transfer. Many cheap cables from power bank kits only charge. If the phone charges but adb devices is empty — first thing, change the cable, not reinstall drivers.
Set Up the Forwarding
- Make sure the proxy on the computer is running and listening on port 8080.
- Run the command:
The first number is the port on the phone, the second is the port on the computer. In response the command prints 8080 or nothing — that's fine.adb reverse tcp:8080 tcp:8080 - Check the list of active forwards:
A line like host-number tcp:8080 tcp:8080 should appear.adb reverse --list - If you have multiple devices connected (e.g., an emulator and a phone), specify the serial number with the -s flag:
adb -s R58M1234ABC reverse tcp:8080 tcp:8080
Point the Phone's Proxy to localhost
There are two paths here. The first — via adb, the fastest:
adb shell settings put global http_proxy 127.0.0.1:8080The second — manually in the phone's Wi-Fi settings, as in Step 4, but enter 127.0.0.1 in the host field and 8080 as the port. The second method is needed on some firmware where the global setting via adb doesn't apply to all apps.
Note an important nuance. The global http_proxy setting is applied by the system to the current network connection. If Wi-Fi is off and the phone is on mobile data, some firmware still applies it and some don't. Most reliably, keep Wi-Fi on (any network, even without a path to the computer) and specify the proxy 127.0.0.1 in its settings. Traffic via adb reverse will go over USB regardless of which Wi-Fi network the phone is connected to.
Install the Certificate
The procedure is the same as before: Chrome → mitm.it → download → install as CA certificate. If the certificate is already installed on this phone from Step 4, no need to repeat.
Disable the Forwarding After Work
- Remove the proxy: adb shell settings put global http_proxy :0 (or "None" in Wi-Fi settings).
- Remove the forward: adb reverse --remove tcp:8080 or all at once: adb reverse --remove-all.
- Note that when you disconnect the cable, forwards reset automatically, but the proxy setting on the phone remains. If you forget to remove it, the phone without the cable is left with no internet. This is exactly what the most common newbie complaint looks like: "the phone won't load anything".
Tip: Write yourself a cheat sheet of three lines: adb reverse tcp:8080 tcp:8080, adb shell settings put global http_proxy 127.0.0.1:8080, adb shell settings put global http_proxy :0. These three commands are enough for 90 percent of work situations with a real device.
Check: Turn off Wi-Fi on the computer or use the phone on a network where the computer is unreachable. Run adb reverse, set the proxy 127.0.0.1:8080, open mitm.it in Chrome on the phone. The certificate download page opened — the forwarding works. Then open the test app and confirm its requests appear in the proxy.
Possible Issues
- adb reverse gives "error: closed" or "more than one device". Multiple devices are connected; specify -s serial_number. Or the device went offline — reconnect the cable.
- The forward is there, but mitm.it doesn't open. Check that the proxy on the computer is listening on 127.0.0.1 or on all interfaces, not only the external IP. mitmproxy defaults to all interfaces. Charles too.
- After reconnecting the cable, traffic disappeared. adb reverse resets on every reconnection. Run the command again. The proxy setting on the phone stays.
Step 6: Intercept and Modify Test Environment Traffic
Goal of this step: you can filter requests to the environment, read request and response bodies, pause a request and modify the server response, emulate errors and a slow network, and point the app at a local backend via adb reverse.
Filter Only What You Need
The app sends dozens of background requests: analytics, config updates, version checks. To avoid drowning, set a filter by the environment's domain.
- In mitmweb, enter an expression like ~d api-stage.example-team.com in the top filter field — only requests to that domain remain. The expression ~u /orders filters by part of the URL, ~c 500 shows only 500-code responses, and ~m POST only POST requests. Expressions can be combined with a space.
- In Charles, enable Focus mode: right-click the environment's host → Focus. The other hosts collapse into the Other Hosts group. Additionally, in the bottom Filter field you can enter part of the URL.
Read the Request and Response So You Can Attach It to a Bug
- Click a request line. In mitmweb, tabs Request, Response, Detail appear on the right. In Charles — tabs Overview, Contents, Summary and switches at the bottom: Headers, JSON Text, Raw.
- Copy the URL, method, response code, and JSON response body. In mitmweb you can right-click a request and choose Export → curl: you get a command the developer can reproduce in a second. In Charles similarly: right-click → Copy cURL Request.
- A good bug report about a network error always contains: steps, URL with method, response code and body, request time (to find it in server logs), and the request ID from headers if the backend returns one (often X-Request-Id).
Pause a Request and Change the Response
A classic scenario: you need to check how the app displays a cart with a hundred items or a negative price, but the environment has no such data. We modify the response.
- In mitmweb, enter a filter in the Intercept field, e.g. ~u /cart. Now all requests with that URL will pause. Perform the action in the app. The request appears marked intercepted. Click it, click Resume after you edit the response in the Response tab (pencil icon). The app receives the modified data.
- In Charles, enable Breakpoints: right-click the request → Breakpoints. On the next such request a window opens with two phases: first Edit Request, then Edit Response. Change the JSON in the Response tab and click Execute.
- Note that apps have a timeout, usually 10-30 seconds. If you edit the response longer, the app will show a network error instead of your data. Prepare the JSON beforehand in a text editor and paste it in whole.
Permanent Response Modification: Map Local
If the scenario repeats, manual pauses are inconvenient. Charles has Tools → Map Local: you specify a URL and a local JSON file, and every such request will receive the file contents instead of the environment's response. In mitmproxy the analog is the map_local option with a URL pattern and file path, plus small Python scripts with a response function that can change any fields. For example, a five-line script can replace the value of the balance field with the number you need in all environment responses.
Emulate Server Errors
How does the app behave on a 500, 401, or empty response? Hard to check on the environment, easy via proxy. In Charles: Tools → Rewrite → add a rule for the environment URL with type Response Status and value 500. In mitmproxy: in intercept mode change the status code in the response editor, or use a script with flow.response.status_code = 500. Verify the app shows a clear error instead of crashing or hanging on an endless loader.
Emulate a Slow Network
In Charles enable Proxy → Throttle Settings, choose a 3G preset or set your own values: bandwidth, latency, packet loss percentage. Don't forget to limit Throttle to the environment host only, otherwise other connections slow down too. Test list loading, request cancellation on leaving a screen, and timeout behavior. The Android emulator can also limit network: Extended Controls → Cellular → Network type, but the proxy gives finer control.
Point the App at a Local Backend
A common task: a developer spun up a server on their laptop on port 3000 and asks you to check a feature before it goes to the environment. The app on a real phone can't see their localhost. The solution is the same adb reverse:
adb reverse tcp:3000 tcp:3000Now in the app (via a hidden environment selection menu or base URL setting in the QA build) specify http://localhost:3000, and requests go to the computer. If you also need interception, keep the proxy on: mitmproxy will see requests to localhost:3000 as regular ones. On the emulator, instead of adb reverse you can just use the address http://10.0.2.2:3000.
Tip: Save sessions. In Charles — File → Save Session, in mitmproxy — the command mitmdump -w session.mitm or the save button in mitmweb. A session file with a bug reproduction is worth more than any description: the developer opens it and sees all requests in the same order they went for you.
Check: You can: show only requests to the environment; copy any request as curl; pause a request and return modified JSON that displays on the screen; make the app get a 500 code and see its reaction; slow down the network and see the loading indicator. If all five points worked — you've mastered the proxy at a confident user level.
Result Check: Final Checklist
Go through the list and tick each item. All of them must be done — then the environment is fully ready for daily work.
Proxy on the Computer
- mitmweb or Charles starts without errors and listens on its port.
- The command curl -x http://127.0.0.1:8080 -k https://example.com displays the request in the interface.
- The root certificate file is found and you know where it is.
Emulator
- adb devices shows the emulator with status device.
- adb shell settings get global http_proxy returns 10.0.2.2:8080 or the Extended Controls panel shows Success.
- Chrome in the emulator opens HTTPS sites without warnings.
- The certificate is visible in the User tab in security settings.
- The test app works and its requests to the environment are visible with decrypted bodies.
Real Device
- USB debugging is on, adb devices sees the phone.
- Over Wi-Fi: proxy set to the computer's IP, mitm.it opens, app requests visible.
- Over USB: adb reverse --list shows tcp:8080, proxy 127.0.0.1:8080 is set, mitm.it opens with the computer's Wi-Fi off.
- You can disable the proxy and the forward, and after disabling the phone goes online normally.
Working with the Environment
- A filter by the environment's domain is set up.
- At least one response modification was done via pause or Map Local.
- The app's reaction to a 500 code was verified.
- A session with sample traffic was saved.
Self-Check Test Scenario
- Start the proxy, the emulator, and enable the proxy on the emulator.
- Open the app, log in, open any data list.
- In the proxy, find the request that returned the list. Set an intercept on its URL.
- Refresh the list in the app, in the paused response delete half the items, release.
- The app screen should show fewer items. If yes — the environment is fully working.
Common Mistakes and Solutions
Problem 1: App Shows a Network Error but the Browser Works
Cause: the app doesn't trust the user certificate (Android 7+ default behavior) or certificate pinning is enabled. Solution: request a debug build with network_security_config and the debug-overrides block, or a QA build with pinning disabled for the environment. As a temporary option on a Google APIs emulator — a system certificate. Checking the cause is helped by adb logcat with a filter on the word Trust or pinning.
Problem 2: No Requests At All, Even Though the Proxy Is Set
Cause: the app uses a network library that ignores the system proxy. This is how Flutter apps (dart:io client), some React Native builds, and gRPC apps behave. Solution: for Flutter the developer adds support for the system proxy in the debug build via a package that reads proxy settings, or explicitly sets findProxy to 10.0.2.2:8080 in debug mode. This is a standard request; Flutter developers know it. The alternative is transparent proxy mode, but it's more complex and not covered here.
Problem 3: Phone Has No Internet After Testing
Cause: the proxy remained in Wi-Fi settings or in the global http_proxy setting, and the proxy server is off or the cable is disconnected. Solution: adb shell settings put global http_proxy :0, and set the Wi-Fi proxy to "None". Add this action to the end of your work ritual.
Problem 4: adb Doesn't See the Device
Cause: a charging-only cable, the debugging prompt wasn't confirmed, the driver isn't installed on Windows, the device is in "Charging only" mode instead of "File transfer". Solution: change the cable, check the phone screen, switch the USB mode in the notification shade to "File transfer", on Windows install the Google USB Driver via SDK Manager or the manufacturer's driver. Also helps: adb kill-server and then adb start-server.
Problem 5: Charles Shows Only CONNECT Without Content
Cause: SSL Proxying isn't enabled or the domain isn't added to Include. Solution: Proxy → SSL Proxying Settings → Enable → Add host * port 443. After enabling, reopen the app: already established connections won't decrypt retroactively.
Problem 6: Proxy status: Error in the Emulator Panel
Cause: the proxy on the computer isn't running or the port is different. Sometimes Android Studio intercepts settings with its own proxy. Solution: start the proxy, uncheck the use Android Studio settings box, click Apply again. If that doesn't help — set the proxy via adb with the 10.0.2.2 address.
Problem 7: mitm.it Doesn't Open, but the Rest of the Internet Works
Cause: traffic is bypassing the proxy. On a real device over Wi-Fi, client isolation in the network is often to blame. Solution: check ping to the phone from the computer. No reply — switch to adb reverse. There is a reply — check the firewall and port.
Problem 8: Certificate Disappeared After an Android Studio Update
Cause: you did a Wipe Data on the emulator or recreated it. Solution: the user certificate takes a minute to install via mitm.it. To avoid losing state, use emulator snapshots (Snapshots in Extended Controls): save a snapshot after installing the certificate and app.
Problem 9: Multiple Devices and Commands Go to the Wrong One
Cause: adb without the -s flag refuses to work with two or more connected devices or works with an unexpected one. Solution: always use adb -s serial_number, and check serial numbers via adb devices. You can set the ANDROID_SERIAL environment variable to the desired number.
Additional Capabilities for Advanced Testers
iOS Simulator and a Real iPhone
The logic is the same, the tools are different. The iOS simulator uses macOS network settings, so the proxy is set in System Settings → Network on the Mac, and the certificate is dragged into the simulator window and enabled in Settings → General → About → Certificate Trust Settings. On a real iPhone the proxy is set in Wi-Fi properties, the certificate is downloaded via mitm.it and activated along the same path with trust. There's no adb reverse analog for iPhone over USB; in closed networks people use internet sharing from the Mac over cable.
Automation with mitmdump and Scripts
mitmdump runs without an interface and accepts Python scripts. Example task: replace the feature_flags field in all environment responses to enable an experimental feature without admin access. The script is launched with the -s script.py flag, and traffic is written to a file with the -w flag. Such scripts are convenient to store in the test repository next to autotests.
Integration with Appium and Autotests
In autotests the proxy is enabled before starting a session: setup via adb, then assertions not only on the UI but also on traffic. For example, a test taps "Pay" and checks that a POST to /payments with the right amount appeared in mitmproxy. This catches bugs the UI doesn't show: duplicate requests, extra fields being sent, wrong date formats.
Checking Analytics and Tracking
A proxy is indispensable for testing analytics events: you see which events and with which parameters the app sends on each action. Filtering by the analytics system's domain and the request body column replaces long waits for events to appear in dashboards.
Multiple Emulators with Different Proxies
If you need to compare behavior with different environment responses, run two proxies on ports 8080 and 8090 and two emulators, each with its own proxy via adb -s. This is convenient for checking A/B variants: one emulator gets a modified response via Map Local, the second gets the original.
Emulator Snapshots as a Clean Environment
After setting up the proxy, certificate, and app, save an emulator snapshot. Before each test run, load it — and you get an identical environment in seconds, without reinstalling.
Environment Separation and Security
Keep separate Charles profiles or mitmproxy configurations for different projects. Don't enable system-wide interception of all computer traffic — only device traffic. And periodically check that test devices have no personal accounts, since all their traffic is visible in the proxy.
FAQ: Common Questions About Proxy Setup in Mobile Testing
What's the Difference Between adb reverse and adb forward?
adb reverse makes a port on the device lead to the computer: an app on the phone accesses localhost and reaches the PC. adb forward is the opposite: a computer port leads to the device, which is how you connect, e.g., to a debugger or a web server inside the phone. For a proxy and a local backend, you need reverse.
Do I Have to Install the Certificate if I Only Care About Request URLs?
No. Without the certificate you'll see hosts and CONNECT requests, but not paths, parameters, and bodies. However, the app will then get TLS errors, so you won't be able to test it properly. In practice people always install the certificate.
Why Is the Computer's Address 10.0.2.2 in the Emulator but 127.0.0.1 in the Extended Controls Panel?
The emulator panel applies the proxy on the host-machine side, so there the computer's address is 127.0.0.1. And the adb shell command runs inside Android, where 127.0.0.1 is the emulator itself and the computer is reachable at 10.0.2.2. Remember the rule: inside Android — 10.0.2.2, outside — 127.0.0.1.
Can I Use a Proxy on a Device Without Root?
Yes. Everything described in the guide except installing a system certificate works without root. The key condition is a debug build that trusts user certificates.
What to Do if the App Stopped Working Through the Proxy After a Build Update?
Most likely the developers enabled pinning or removed debug-overrides. Check adb logcat for certificate errors and ask the team what changed in the network configuration. This often happens when switching to a new HTTP client library.
How Do I Test the App Through a Proxy Using Mobile Data Instead of Wi-Fi?
Use adb reverse over USB and a global http_proxy 127.0.0.1:8080 setting. On most devices the proxy will apply to mobile data too. If not — test over Wi-Fi, and check network-switching scenarios separately without the proxy.
Can I Intercept Traffic of a Production Version from the Store?
Technically, release builds don't trust user certificates and often contain pinning, so without modifications it doesn't work. And that's correct: user protection matters more than tester convenience. Do all checks on test builds and the environment.
How Do I Know a Request Came from the App and Not a Background Service or Browser?
Charles has a Client Process column on macOS, while on a device, process information isn't transmitted. A practical trick: close all other apps, filter by the environment's domain, and reproduce the action precisely. In doubtful cases look at the User-Agent header — apps usually include their name and version.
How Do I Save Traffic and Hand It to a Developer?
In Charles — File → Save Session As in .chls format or Export as HAR. In mitmproxy — the -w flag to record or saving from the web interface. HAR is readable by almost any tool, including the Network tab in browser developer tools.
How Long Does Daily Setup Take After the First Time?
Starting the proxy, the emulator from a snapshot, and enabling the proxy via adb — about a minute. A real device over USB — two commands and ten seconds. Certificate setup repeats only after a device reset.
Conclusion
Let's sum up. You set up an intercepting proxy on your computer and confirmed it sees traffic. You routed the Android emulator into it in three different ways and got to grips with the addresses 127.0.0.1 and 10.0.2.2. You installed the root certificate and understood why the app may not trust it and what exactly to ask the developers for. You connected a real device over Wi-Fi, hit the limits of office networks, and solved them with port forwarding via adb reverse. You learned to filter environment traffic, pause requests, modify responses, emulate server errors and a slow network, and point the app at a colleague's local backend.
This is the skill set that distinguishes a mobile tester who can find and localize network bugs independently. Your bug reports will be more precise, and developers will be grateful for ready-made curl commands and session files.
What to Do Next
- Repeat the setup on your work project and get decrypted requests to the environment showing up.
- Make yourself a cheat sheet of adb commands and save an emulator snapshot with a ready environment.
- Run one full feature test cycle with the proxy open and count how many bugs were found thanks to traffic visibility.
Where to Grow
The next level is Python scripts for mitmproxy that modify responses automatically, integrating traffic checks into Appium autotests, and testing the environment API directly via Postman or curl in parallel with the mobile client. It's useful to learn the basics of TLS and certificate structure to talk confidently with developers about pinning and network security configuration. And be sure to master the iOS side: commands that test both clients value specialists who are equally confident on both platforms. You've got this — you've already done the hardest part.