11

Genymotion 2.2 & Android 4.0

I want to set a global HTTP proxy in Android, and all Apps will go through this proxy.

Now I can only do this in GUI as following way: Wi-Fi -> WiredSSID -> Modify Network -> show advanced options

Is there any way to set the WIFI proxy via adb shell?

I've Googled and tried several ways such as:

 1. export http_proxy xxx
 2. setprop net.gprs.http-proxy xxx
 3. sqlite3 /data/data/com.android.providers.settings/databases/settings.db; INSERT INTO system VALUES(99,'http_proxy','xxx.xxx.xxx.xxx:xxxx')

and nothing worked.

1

4 Answers 4

34

On my Android 7 and 8 devices:

adb shell settings put global http_proxy <address>:<port>

Seems the setting is lost at reboot, however.

2
5

on master device:

  1. Configure wifi proxy manually
  2. adb pull /data/misc/wifi/ipconfig.txt

on second device:

  1. adb shell svc wifi disable
  2. adb push ipconfig.txt /data/misc/wifi/ipconfig.txt
  3. adb shell svc wifi enable
1

I posted this over in this StackOverflow question and it looks like it would work for what you are trying to do.

I developed an app that will allow you to change the proxy from adb for use in my own automation setup and it has been working reliably for me so far. You can look at the source and download the apk from github. All you have to do is install it on the device you want to automate proxy changes and then run an adb command to have the app set your proxy settings. More details on how to use it are in the README on github.

2
  • We used a method like this for some time but for anyone reading, it only works for Android <6. Jun 22, 2018 at 6:17
  • @Crummy maybe it was true at that time. It works for Android 6.0 and 7.0 now.
    – Sufian
    Nov 15, 2018 at 15:09
0

for removing the proxy, adb shell settings put global http_proxy :0. i struggled with my android phone after setting the wrong proxy. not sure if there's any default settings via GUI in the android settings, I'm using an Android lollipop OS phone so not many options there. To check that you've set the wrong proxy, if you get errors like Caused by: java.net.ConnectException: failed to connect to /127.0.0.1 (port 1337): connect failed: ECONNREFUSED (Connection refused), a very likely cause would be wrong proxy.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .