Use wget/curl behind a proxy

If your machine is behind a proxy, you probably configured your browser for going through the proxy to reach Internet. But what about command line with curl and wget?

If you want to add the proxy temporarily for some few installations for example, just type (by replacing URL and port with yours):

export http_proxy=http://MyProxyURL:3128
export https_proxy= http://MyProxyURL:3128

If you want to make the changes globally and keep it after a restart (or a new login), you can:

  • Add those lines in ~/.wgetrc to make it available only for wget and for the current user
    http_proxy=http://MyProxyURL:3128
    https_proxy=http://MyProxyURL:3128
    use_proxy=on
    wait=15
    
  • Add those lines in /etc/environment to make it work for either curl/wget or any http relevant command:
    http_proxy=http://MyProxyURL:3128
    https_proxy=http://MyProxyURL:3128
    

If you need authentication, you can simply include username and password in your connection string like:

http_proxy = http://username:password@MyProxyURL:3128