38

I'm working behind a proxy. When I installed homebrew I've modified the official command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 

by adding a -x option to tell curl about the proxy:

/usr/bin/ruby -e "$(curl -x proxy.mydomain.com:3128 -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 

and it works well. But now I want to install openssl:

brew install openssl 

and logically, the proxy is not detected:

curl: (7) Failed to connect to homebrew.bintray.com port 443: Connection refused Error: Failed to download resource "openssl" 

If I set the environment variables as described in the documentation:

http_proxy=proxy.mydomain.com:3128 HTTPS_PROXY=proxy.mydomain.com:3128 ALL_PROXY=proxy.mydomain.com:3128 

I obtain the same error. Adding http: or https: before doesn't change the problem.

Any ideas?

5 Answers 5

68

To run Homebrew or Curl behind a proxy :

export ALL_PROXY=$http_proxy:port 

or

export ALL_PROXY=proxyIP:port 

After this is done, installation worked smoothly.

6
  • $http_proxy is not defined usually. Commented Mar 28, 2016 at 9:40
  • 5
    Setting $ALL_PROXY worked for me. Commented Aug 9, 2016 at 12:36
  • 1
    Depending on the brew command you use, you also have to set the proxy for git with git config --global http.proxy http://proxyuser:[email protected]:8080 Commented Oct 23, 2016 at 13:49
  • curl: (22) The requested URL returned error: 501 Commented May 6, 2022 at 11:24
  • Works on zsh shell, doesn't work on fish shell.. so surprising Commented Jul 4, 2022 at 13:50
11

Try run brew like this:

http_proxy=https://user:password@proxy:port https_proxy=https://user:password@proxy:port brew install PACKAGE 

The source is here: https://juanchorossi.com/osx-set-brew-proxy-server/

8

For SOCKS5 proxy:

ALL_PROXY=socks5://127.0.0.1:9001 brew upgrade 
2
all_proxy=<proxy_domain>:<port> brew install <package> 

I didn't explicitly include the http:// or https:// prefix in the proxy domain. Worked for me with macOS Sierra and Homebrew 1.2.4.

1

In terminal, type this:

http_proxy=http://IP:PORT https_proxy=http://IP:PORT brew install PACKAGE 

for me, was behind IIIT proxy and trying to install python3, so this worked:

http_proxy=http://proxy.iiit.ac.in:8080 https_proxy=http://proxy.iiit.ac.in:8080 brew install python3 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.