If on macOS the command brew install hangs during download or fails with a curl error, it is likely due to the proxy: either it is not configured at all, or Homebrew and curl are using different environment variables. Let's explore how to make brew work correctly through a proxy in 2026, which variables need to be set, and how to diagnose typical curl errors like "SSL certificate problem" and "Could not resolve host".
Why Homebrew does not see the proxy
Homebrew itself does not have a separate config for proxies — it relies on standard shell environment variables and how they are read by curl, git, and Ruby (brew is written in Ruby and uses its network stack for some operations). If you have configured the proxy only in the macOS system settings via "System Preferences → Network → Proxies", this works for browsers and some system applications, but the terminal and brew do not see it — they need explicit HTTP_PROXY and HTTPS_PROXY variables in the terminal session.
The second common reason is that different components of brew access the network in different ways. The package manager itself downloads formulas and bottles via curl, but operations with the core repository (tap) go through git, and git reads a completely separate set of proxy settings specified in ~/.gitconfig. If you configure only curl but forget about git, you will get a working brew install, but a hanging brew update.
The third reason is protocol incompatibility. As of 2026, many corporate and residential proxies operate over HTTPS CONNECT or SOCKS5, and if the wrong protocol is specified in the environment variable (for example, http:// instead of socks5://), curl simply cannot establish a tunnel and will throw a connection error, even if the proxy server is functioning.
Setting environment variables for brew
The most reliable way to make brew work through a proxy is to export environment variables right before the command or in the current terminal session. This allows you to quickly check if the proxy works without touching configuration files.
export HTTP_PROXY="http://login:password@proxy_host:port"
export HTTPS_PROXY="http://login:password@proxy_host:port"
export ALL_PROXY="socks5://login:password@proxy_host:port"
brew update
brew install wget
If the proxy does not require authentication, simply remove the login:password@ block. Note: some versions of curl and Ruby are case-sensitive with variables — for maximum compatibility, duplicate the variables in lowercase:
export http_proxy="$HTTP_PROXY"
export https_proxy="$HTTPS_PROXY"
export all_proxy="$ALL_PROXY"
If you need to temporarily disable the proxy for specific internal hosts (for example, when working in a corporate network with a local package mirror), add the NO_PROXY variable:
export NO_PROXY="localhost,127.0.0.1,.internal.company.com"
Configuring curl via .curlrc
Homebrew actively uses curl under the hood to download package archives (bottles). If environment variables are not enough or you want the settings to apply to all curl calls in the system, not just the brew session, create a file ~/.curlrc:
proxy = "http://proxy_host:port"
proxy-user = "login:password"
connect-timeout = 30
retry = 3
The connect-timeout parameter is particularly important for proxies: residential and mobile IPs sometimes respond with a delay of 2-5 seconds due to routing through real devices, and the default curl timeout in some versions may trigger before the proxy can respond. Increasing the timeout to 30-60 seconds reduces the number of false disconnections during downloads.
To check that curl is indeed reading the configuration file, perform a test request with the verbose output flag:
curl -v https://formulae.brew.sh/api/formula.json
The output should contain a line like Trying proxy_host:port... — if it is not there, then the proxy was not picked up and you need to check the path to the file or the syntax of the environment variables.
Analyzing typical curl errors
In practice, when working with brew through a proxy, four recurring errors are encountered. Let's analyze each and how to resolve it.
| Curl Error | Cause | Solution |
|---|---|---|
| curl: (60) SSL certificate problem | The proxy performs MITM inspection of SSL traffic and replaces the certificate | Add the proxy's root certificate to the trusted certificates in macOS |
| curl: (7) Failed to connect | Incorrect host/port for the proxy or the proxy is unavailable | Check the proxy's availability with the command telnet host port |
| curl: (6) Could not resolve host | DNS does not resolve through the proxy tunnel | Use socks5h:// instead of socks5:// to resolve DNS on the proxy side |
| curl: (28) Operation timed out | The proxy responds slowly or is overloaded | Increase connect-timeout, change the proxy server |
Special attention should be paid to the DNS resolution error. By default, when using a SOCKS5 proxy, curl resolves domains locally and then only contacts the proxy to establish a connection. If the proxy is on a different network or you are using the proxy specifically for geo-testing, DNS requests should go through the proxy server itself — for this, specify the socks5h:// protocol in the environment variable and in brew settings instead of socks5://.
Proxy for git and brew tap
The command brew update and connecting to third-party tap repositories work through git, not directly through curl. Therefore, even if curl is configured perfectly, git may continue to hang. Configure the proxy separately for git:
git config --global http.proxy http://login:password@proxy_host:port
git config --global https.proxy http://login:password@proxy_host:port
To check that git sees the proxy, run:
git config --global --get http.proxy
If you need to temporarily disable the proxy for git without completely removing the setting:
git config --global --unset http.proxy
git config --global --unset https.proxy
Persistent configuration in zshrc
Exporting variables manually each time is inconvenient if you regularly work through a proxy — for example, testing the availability of packages from different regions or using a proxy to bypass geo-blocks of Homebrew mirrors. Write the variables in ~/.zshrc (the default shell in modern macOS):
cat << 'EOF' >> ~/.zshrc
# Proxy for Homebrew and curl
export HTTP_PROXY="http://login:password@proxy_host:port"
export HTTPS_PROXY="http://login:password@proxy_host:port"
export http_proxy="$HTTP_PROXY"
export https_proxy="$HTTPS_PROXY"
export NO_PROXY="localhost,127.0.0.1"
EOF
source ~/.zshrc
If the proxy is only needed occasionally, it is more convenient to create toggle aliases instead of permanent variables:
alias proxy_on='export HTTP_PROXY="http://proxy_host:port"; export HTTPS_PROXY="$HTTP_PROXY"'
alias proxy_off='unset HTTP_PROXY HTTPS_PROXY'
This is especially convenient for developers who switch between testing in their home network and simulating access from other countries or devices.
Which type of proxy to choose for brew
For Homebrew itself, in most cases, a stable and fast proxy will suffice, as the task boils down to downloading large files (package bottles) with minimal anonymity requirements. Data center proxies work well here — they provide high speed and low latency, which is critical for downloading archives of hundreds of megabytes without connection drops.
However, if the developer's task is broader — for example, testing the availability of Homebrew mirrors from different countries, checking CDN behavior, or simulating location for a CI/CD pipeline that should mimic a real user — a data center IP may be recognized and blocked as a bot. In this case, it makes more sense to use residential proxies, as they use IP addresses from real providers and are perceived by servers as regular home traffic.
A separate case is testing mobile installation scenarios through terminal applications on mobile devices or emulators, where maximum fidelity to a mobile operator is required. For such tasks, mobile proxies are used, which provide IPs from real cellular operators.
| Task | Recommended type of proxy |
|---|---|
| Downloading brew packages, speed is more important than anonymity | Data center proxies |
| Testing the availability of mirrors from different regions | Residential proxies |
| Simulating a mobile network environment | Mobile proxies |
Diagnostics and connection check
Before dealing with brew settings, make sure the proxy is working in general. Perform a direct request to the proxy server:
curl -x http://login:password@proxy_host:port -v https://httpbin.org/ip
If the command returns JSON with the external IP address of the proxy, then the connection is working and the problem lies specifically in the brew settings or curl configuration, not in the proxy server itself. Next, check that brew is using the system curl, not its own build:
brew config | grep -i curl
The command brew doctor is also useful for identifying environment conflicts, although it does not always directly indicate a proxy problem — pay attention to warnings about environment variables and permissions to Homebrew/Library/Caches.
For detailed diagnostics at the network level, run the installation with maximum verbose information:
HOMEBREW_CURL_VERBOSE=1 brew install wget
This variable causes Homebrew to output the full log of curl requests, including the stage of establishing a connection through the proxy, which immediately shows at which step the connection is breaking.
Troubleshooting checklist
- Checked that the proxy responds directly via
curl -x - Exported HTTP_PROXY and HTTPS_PROXY in the current terminal session
- Duplicated variables in lowercase (http_proxy, https_proxy)
- Configured git config separately for http.proxy and https.proxy
- Checked the ~/.curlrc file for correct syntax
- Used socks5h:// instead of socks5:// when having DNS issues
- Increased connect-timeout when working with residential or mobile IPs
- Added the proxy certificate to Keychain if it performs SSL inspection
- Ran brew install with HOMEBREW_CURL_VERBOSE=1 for detailed logging
Conclusion
The main reason why Homebrew does not download packages through a proxy is the desynchronization of settings between curl, git, and shell environment variables. Export HTTP_PROXY and HTTPS_PROXY in both lowercase and uppercase, configure git config separately for tap repositories, and if there are SSL errors, add the proxy certificate to the system store. For diagnostics, use the HOMEBREW_CURL_VERBOSE flag and direct curl -x requests to the proxy server — this will quickly show at which step the connection is breaking.
If your task goes beyond simple package downloads and requires stable network access with high speed, consider data center proxies — they are well suited for CI/CD environments and regular builds. For tasks where the accuracy of geolocation and simulating a real user is important, residential or mobile IPs are better suited, as discussed above in the section on choosing the type of proxy.