Question: While downloading using wget, I get the following error “Connecting to <URL>.. failed: Connection refused.”. I’m behind a proxy server. How do I fix it?
Answer: Export the http_proxy variable with your proxy server name or ip address and then try downloading as explained below.
Connection refused error while using wget
If http_proxy environment variable is not set, you might receive the following message while downloading files from Internet using wget.
$ wget -O DrawIt.vba.gz http://www.vim.org/scripts/download_script.php?src_id=8798 --12:58:32-- http://www.vim.org/scripts/download_script.php?src_id=8798 => `DrawIt.vba.gz' Resolving www.vim.org... 18.104.22.168 Connecting to www.vim.org|22.214.171.124|:80... failed: Connection refused.
Export HTTP_PROXY Variable
Specify your proxy server name (or) ip-address (along with any port number if necessary) in the http_proxy variable as shown below.
$ export http_proxy='proxy_server_ip:8080'
Use colon ( : ) as delimiter between ip/host and port number. Following is an example.
$ export http_proxy='http://myproxy.cmp.com:8080/'
Now, you should be able to download using wget without any issue.
$ wget -O DrawIt.vba.gz http://www.vim.org/scripts/download_script.php?src_id=8798 --12:59:02-- http://www.vim.org/scripts/download_script.php?src_id=8798 => `DrawIt.vba.gz' Resolving proxy.sgp.hp.com... 126.96.36.199 Connecting to proxy.sgp.hp.com|188.8.131.52|:8080... connected. Proxy request sent, awaiting response... 200 OK Length: unspecified [application/octetstream] [ ] 21,668 --.--K/s 12:59:04 (164.19 KB/s) - `DrawIt.vba.gz' saved 
Get the Linux Sysadmin Course Now!