Setting Homebrew User Agent for restrictive proxy

This post is intended to help anyone who is having trouble using Homebrew using a proxy. A symptom of this is the error message:

curl: (22) The requested URL returned error: 407 or

curl: (22) The requested URL returned error: 407 Proxy Authentication Required

This is generally unhelpful and verbose mode does not add any more useful information.

(Note: this is not the same problem as not setting the env variables http_proxy and https_proxy which may show the same symptoms)

Recently this started happening to me after a forced company upgrade of my mac to Sierra which broke Homebrew and started displaying the above error for every action.

It took me a couple hours of going through bash and Ruby code and much trial and error to find what can be fixed with a simple script line change.

Hopefully your problem is the same and it fixes it.

My problem was that the company proxy was not allowing certain user agents through. One of these was the user agent that is set by Homebrew and used as an argument to curl.

I tested using curl with argument –user-agent “” to verify.

The Homebrew maintainer has refused to address this as explained here

The fix involves setting the Homebrew curl user agent to one of your choosing.

Find this file in your Homebrew install: /usr/local/Homebrew/Library/Homebrew/

Find the text “HOMEBREW_USER_AGENT_CURL” and change it accordingly. I used “IE ” and it worked.

This will be reverted on a Homebrew update which it tries to do often. To avoid this set this environment variable HOMEBREW_NO_AUTO_UPDATE=1 either in your ~/.bash_profile or before you run a Homebrew command.

Homebrew should work fine now using the proxy.


This entry was posted in curl, Homebrew, mac os, proxy. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s