This guide explains how to block internet access (Wi-Fi and mobile data) for a specific app using ADB.
This method works without root and is compatible with Android 10 and up.
This guide assumes you know how to use ADB. If you do not, see the other forum posts on using ADB before using this guide.
Connect to ADB and folllow the steps below:
Step 1: Find the App’s Package Name
To find the package name of the app you want to block:
adb shell pm list packages | grep appname
Replace appname with a keyword from the app’s name. For example:
adb shell pm list packages | grep groupme
⸻
Step 2: Block Internet Access
You can use the cmd netpolicy tool to restrict background and foreground data.
Block All Network Access (Mobile + Wi-Fi)
adb shell cmd netpolicy add restrict-background PACKAGE_NAME
Replace PACKAGE_NAME with the actual package name (e.g. com.groupme.app).
Optional: Block Foreground Data on Android 11+
On Android 11 and higher, apps may still access data in the foreground. To block all network access (foreground too), you’ll need to toggle Data Saver mode ON, then apply background restrictions.
Enable Data Saver (manually on the phone):
• Go to Settings > Network & Internet > Data Saver and turn it ON.
Then the background restriction will effectively block all data access for apps.
Step 3: Verify the Restriction
Run this to check if the app is restricted:
adb shell cmd netpolicy list restrict-background
You should see your app’s package name in the list.
Re-enable Internet Access
To remove the restriction:
adb shell cmd netpolicy remove restrict-background PACKAGE_NAME
Notes:
• This method does not block local network access (e.g., communicating with other devices on the same Wi-Fi).
• Some apps may not obey restrictions and require a firewall app for full blocking.
• On Android 9 and below, these commands may not work or require root.