Set or Clear an HTTP Web Proxy

Configure the macOS web (HTTP) proxy for a network service from the terminal with networksetup -setwebproxy.

macOSnetworkproxynetworksetupMedium risk
Run `networksetup -setwebproxy "Wi-Fi" <proxy-address> <port>` then `-setwebproxystate "Wi-Fi" on`; turn it off again with `-setwebproxystate "Wi-Fi" off`.

01Command

Command
$ networksetup -setwebproxy "Wi-Fi" 127.0.0.1 8118 && networksetup -setwebproxystate "Wi-Fi" on

02What it does

This sets the same 'Web Proxy (HTTP)' fields as System Settings > Network > Details > Proxies, per network service — so Wi-Fi and Ethernet can have different settings. Browsers that use system settings (Safari, and Chrome by default) pick it up immediately. A wrong proxy address makes all web traffic fail with connection errors, so remember the off switch in undoCommand.

03Risk

RiskMedium risk
RequirementsReplace the address and port with your real proxy server; this affects only the chosen network service (e.g. Wi-Fi).
!Warning: A mistyped proxy address will break all web browsing on that service — if pages stop loading, turn the proxy state off again.

04Undo

Undo
$ networksetup -setwebproxystate "Wi-Fi" off

05Sources

Last verified: 2026-09-18 · Category: Network