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

by SathiyaMoorthy on July 23, 2010

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
           => `DrawIt.vba.gz'
Connecting to||: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=''

Now, you should be able to download using wget without any issue.

$ wget -O DrawIt.vba.gz
           => `DrawIt.vba.gz'
Connecting to||: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]

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

{ 5 comments… read them below or add one }

1 Hector Lara July 23, 2010 at 12:03 pm

Also su can use this configuration for ftp proxy
export ftp_proxy=’’

2 Hector Lara July 23, 2010 at 12:06 pm

I forget it you can avoid http_proxy for some local or intranet sites with:
export no_proxy=localhost,,*.local,*,,*

3 abanggeh August 5, 2010 at 12:42 am

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

4 Abhijat August 23, 2010 at 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.


5 sudheer October 25, 2012 at 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.

Leave a Comment

Previous post:

Next post: