≡ Menu

How to Fix wget Connection Refused Error when I’m behind a Proxy

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... 216.34.181.97
Connecting to www.vim.org|216.34.181.97|: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... 16.158.235.10
Connecting to proxy.sgp.hp.com|16.158.235.10|: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 [21668]
Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • Hector Lara July 23, 2010, 12:03 pm

    Also su can use this configuration for ftp proxy
    export ftp_proxy=’http://myproxy.cmp.com:8080/’

  • Hector Lara July 23, 2010, 12:06 pm

    I forget it you can avoid http_proxy for some local or intranet sites with:
    export no_proxy=localhost,127.0.0.0/8,*.local,*.foo.com,192.168.1.0/24,*.foo.corp.com

  • abanggeh August 5, 2010, 12:42 am

    You can copy wget configuration from /etc/wgetrc to your_home/.wgetrc
    Edit and change http_proxy configuration.

  • Abhijat August 23, 2010, 3:45 pm

    Hi group,
    I have a straight forward question. I have ftp proxy’s link, user id and password. Then I have ftp site’s link, user id and password. Can I have some unix shell script that uses all this information and wget to download the files from the ftp site?
    Thanks very much for your help.

    Abhijat.

  • sudheer October 25, 2012, 11:25 pm

    [root@hostname ~]# wget http://domainname/text.txt
    –2012-10-26 06:13:45– http://domainname/text.txt
    Resolving …
    Connecting to ||:80… failed: Connection timed out.
    Retrying.