MacOS – Setting proxy settings to “Auto Proxy Detection” using the command line in macOS

bashmacosPROXY

I want to know how to set the proxy settings to “Auto Proxy Detection” like in network preferences, but using the shell.

I have tried looking around but I only am finding commands like:

networksetup -gethttpproxy

Best Answer

A quick look at the output of networksetup -help shows us some promising options:

I'm not sure whether you want "auto detection" or "auto setup", but both ways are provided:

networksetup -setproxyautodiscovery <networkservice> <on off>
networksetup -setautoproxyurl <networkservice> <url>

The "network service" is the "name" of the connection as shown in the network preferences.

As an example, to enable auto discovery on your Ethernet, you'd run:

networksetup -setproxyautodiscovery Ethernet on

For future usage, remember the -help trick. Most commands you can find provide something along the lines of --help or -help or -? to get further information.

Related Question