How to Set Up a Proxy on macOS Sequoia and Sonoma

How to Set Up a Proxy on macOS Sequoia and Sonoma

Configuring a proxy on macOS is a critical skill for professionals working with data collection, account management, or any task that requires routing internet traffic through an intermediary server. Apple’s macOS provides built-in proxy support through System Settings, and power users can also configure proxies via the Terminal for more granular control.

This guide covers every method for setting up HTTP, HTTPS, and SOCKS5 proxies on macOS Sequoia (macOS 15) and macOS Sonoma (macOS 14), along with troubleshooting tips and best practices.

Why Configure a Proxy on macOS

A proxy server routes your internet traffic through a different IP address before reaching its destination. This is essential for:

  • Data collection and web scraping — Route requests through different IPs to avoid rate limiting. Learn more in our web scraping proxy guide.
  • Privacy and anonymity — Hide your real IP address from websites
  • Geo-testing — Access content as if you were in a different country
  • Network security — Route traffic through a secure gateway in corporate environments
  • Multi-account management — Assign different IPs to different workflows

Method 1: Configure a Proxy via System Settings (GUI)

This method applies a system-wide proxy that most macOS applications will respect, including Safari, Mail, and other apps that use the system network stack.

Step 1: Open Network Settings

  1. Click the Apple menu in the top-left corner and select System Settings (on Sonoma or Sequoia).
  2. Click Network in the left sidebar.
  3. Select your active network connection (e.g., Wi-Fi or Ethernet).
  4. Click Details next to your connected network.

Step 2: Navigate to Proxy Settings

  1. In the network details window, click Proxies in the left sidebar.

Step 3: Configure Your Proxy Type

macOS supports several proxy types. Enable the one that matches your proxy provider’s configuration:

For HTTP Proxy (Web Proxy):

  1. Toggle Web Proxy (HTTP) to On.
  2. Enter the Server address (e.g., proxy.example.com).
  3. Enter the Port (e.g., 8080).
  4. If authentication is required, check Proxy server requires password and enter your Username and Password.

For HTTPS Proxy (Secure Web Proxy):

  1. Toggle Secure Web Proxy (HTTPS) to On.
  2. Enter the same server address and port details.
  3. Enter credentials if required.

For SOCKS5 Proxy:

  1. Toggle SOCKS Proxy to On.
  2. Enter the server address and port (typically 1080 for SOCKS5).
  3. Enter credentials if required.

Step 4: Configure Bypass Domains

In the Bypass proxy settings for these Hosts & Domains field, add any domains or IP addresses that should bypass the proxy. Common entries include:

*.local, 169.254/16, localhost, 127.0.0.1

Step 5: Apply Settings

Click OK to save the proxy configuration. The changes take effect immediately for most applications.

Step 6: Verify the Configuration

Open Safari and visit whatismyipaddress.com. The displayed IP should match your proxy server’s IP address.

Method 2: Configure a Proxy via Terminal (networksetup)

The networksetup command-line utility provides full control over network settings, including proxy configuration. This method is ideal for automation and scripting.

Identify Your Network Service Name

First, determine the name of your active network service:

networksetup -listallnetworkservices

This returns something like:

An asterisk (*) denotes that a network service is disabled.
Wi-Fi
Ethernet
Thunderbolt Bridge

Use the appropriate service name (e.g., Wi-Fi) in the commands below.

Configure HTTP Proxy

# Enable and set HTTP proxy
networksetup -setwebproxy "Wi-Fi" proxy.example.com 8080

# With authentication
networksetup -setwebproxy "Wi-Fi" proxy.example.com 8080 on username password

Configure HTTPS Proxy

# Enable and set HTTPS proxy
networksetup -setsecurewebproxy "Wi-Fi" proxy.example.com 8443

# With authentication
networksetup -setsecurewebproxy "Wi-Fi" proxy.example.com 8443 on username password

Configure SOCKS5 Proxy

# Enable and set SOCKS proxy
networksetup -setsocksfirewallproxy "Wi-Fi" proxy.example.com 1080

# With authentication
networksetup -setsocksfirewallproxy "Wi-Fi" proxy.example.com 1080 on username password

Set Bypass Domains

networksetup -setproxybypassdomains "Wi-Fi" "*.local" "169.254/16" "localhost" "127.0.0.1"

Verify Proxy Settings

# Check HTTP proxy
networksetup -getwebproxy "Wi-Fi"

# Check HTTPS proxy
networksetup -getsecurewebproxy "Wi-Fi"

# Check SOCKS proxy
networksetup -getsocksfirewallproxy "Wi-Fi"

Disable Proxies

networksetup -setwebproxystate "Wi-Fi" off
networksetup -setsecurewebproxystate "Wi-Fi" off
networksetup -setsocksfirewallproxystate "Wi-Fi" off

Method 3: Set Environment Variables for CLI Tools

Many command-line tools on macOS (such as curl, wget, brew, and programming language package managers) use environment variables for proxy configuration.

Temporary (Current Terminal Session)

export http_proxy="http://username:password@proxy.example.com:8080"
export https_proxy="http://username:password@proxy.example.com:8080"
export no_proxy="localhost,127.0.0.1,.local"

Permanent (Add to Shell Profile)

Add the above export commands to your shell configuration file:

For zsh (default on macOS):

echo 'export http_proxy="http://proxy.example.com:8080"' >> ~/.zshrc
echo 'export https_proxy="http://proxy.example.com:8080"' >> ~/.zshrc
source ~/.zshrc

For bash:

echo 'export http_proxy="http://proxy.example.com:8080"' >> ~/.bash_profile
echo 'export https_proxy="http://proxy.example.com:8080"' >> ~/.bash_profile
source ~/.bash_profile

Method 4: Use a PAC File on macOS

Proxy Auto-Configuration (PAC) files allow you to define conditional proxy rules, which is useful when you only want certain traffic routed through the proxy.

Step 1: Create a PAC File

Create a file named proxy.pac:

function FindProxyForURL(url, host) {
    if (shExpMatch(host, "*.local") || host === "localhost") {
        return "DIRECT";
    }
    if (shExpMatch(host, "*.target-site.com")) {
        return "PROXY proxy.example.com:8080";
    }
    return "DIRECT";
}

Step 2: Configure macOS to Use the PAC File

Via System Settings:

  1. Go to System Settings > Network > Wi-Fi > Details > Proxies.
  2. Toggle Automatic Proxy Configuration to On.
  3. Enter the URL to your PAC file (e.g., file:///Users/yourname/proxy.pac).

Via Terminal:

networksetup -setautoproxyurl "Wi-Fi" "file:///Users/yourname/proxy.pac"

Configuring Proxy for Specific macOS Applications

Safari

Safari uses the system proxy settings by default. Any proxy configured in System Settings will automatically apply to Safari.

Terminal Applications (curl, wget)

Use environment variables as shown in Method 3 above. You can also pass proxy settings inline:

curl -x http://proxy.example.com:8080 https://api.ipify.org
curl --socks5 proxy.example.com:1080 https://api.ipify.org

Homebrew

Homebrew respects the standard http_proxy and https_proxy environment variables. Set them before running brew commands:

export ALL_PROXY="http://proxy.example.com:8080"
brew install package-name

Troubleshooting macOS Proxy Issues

Proxy Not Taking Effect

  1. Restart the application — Some apps cache network settings on launch.
  2. Check the correct network interface — Ensure you configured the proxy on the active connection (Wi-Fi vs. Ethernet).
  3. Flush DNS cache: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Authentication Errors

  • Verify your credentials are correct.
  • Special characters in passwords must be URL-encoded in environment variables (e.g., @ becomes %40).
  • Some proxies use IP-based authentication instead of username/password. Ensure your IP is whitelisted.

Slow Performance

Free or overloaded proxies often cause slow connections. For reliable performance, consider using a premium mobile proxy service that provides dedicated bandwidth and low latency.

Apps Ignoring System Proxy

Some applications (like certain VPN clients, Docker, or Electron-based apps) have their own proxy settings and ignore the system configuration. Check the application’s preferences or documentation.

Best Practices

  1. Use SOCKS5 proxies for maximum compatibility and protocol support. For a deeper dive into proxy protocols, visit our proxy glossary.
  2. Script your proxy setup using networksetup commands if you frequently switch between proxy configurations.
  3. Create a shell function to quickly toggle proxies on and off:
proxy_on() {
    networksetup -setwebproxy "Wi-Fi" "$1" "$2"
    networksetup -setsecurewebproxy "Wi-Fi" "$1" "$2"
    echo "Proxy enabled: $1:$2"
}

proxy_off() {
    networksetup -setwebproxystate "Wi-Fi" off
    networksetup -setsecurewebproxystate "Wi-Fi" off
    echo "Proxy disabled"
}
  1. Verify your proxy after every configuration change by checking your public IP.
  2. Keep your macOS updated to ensure you have the latest security patches and network features.

Conclusion

macOS provides robust proxy support through both System Settings and Terminal commands. For most users, the GUI method in System Settings is sufficient. Developers and automation-focused users will benefit from the networksetup command and environment variables, which enable scripted proxy management across multiple configurations. Whatever method you choose, always verify your proxy is active by confirming your public IP address has changed.


Related Reading

Scroll to Top