Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4331462
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:06:45+00:00 2026-05-21T10:06:45+00:00

I familiar with the fact that I should set the HTTP_RPOXY environment variable to

  • 0

I familiar with the fact that I should set the HTTP_RPOXY environment variable to the proxy address.

Generally urllib works fine, the problem is dealing with urllib2.

>>> urllib2.urlopen("http://www.google.com").read()

returns

urllib2.URLError: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>

or

urllib2.URLError: <urlopen error [Errno 11004] getaddrinfo failed>

Extra info:

urllib.urlopen(….) works fine! It is just urllib2 that is playing tricks…

I tried @Fenikso answer but I’m getting this error now:

URLError: <urlopen error [Errno 10060] A connection attempt failed because the 
connected party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond>      

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T10:06:46+00:00Added an answer on May 21, 2026 at 10:06 am

    You can do it even without the HTTP_PROXY environment variable. Try this sample:

    import urllib2
    
    proxy_support = urllib2.ProxyHandler({"http":"http://61.233.25.166:80"})
    opener = urllib2.build_opener(proxy_support)
    urllib2.install_opener(opener)
    
    html = urllib2.urlopen("http://www.google.com").read()
    print html
    

    In your case it really seems that the proxy server is refusing the connection.


    Something more to try:

    import urllib2
    
    #proxy = "61.233.25.166:80"
    proxy = "YOUR_PROXY_GOES_HERE"
    
    proxies = {"http":"http://%s" % proxy}
    url = "http://www.google.com/search?q=test"
    headers={'User-agent' : 'Mozilla/5.0'}
    
    proxy_support = urllib2.ProxyHandler(proxies)
    opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler(debuglevel=1))
    urllib2.install_opener(opener)
    
    req = urllib2.Request(url, None, headers)
    html = urllib2.urlopen(req).read()
    print html
    

    Edit 2014:
    This seems to be a popular question / answer. However today I would use third party requests module instead.

    For one request just do:

    import requests
    
    r = requests.get("http://www.google.com", 
                     proxies={"http": "http://61.233.25.166:80"})
    print(r.text)
    

    For multiple requests use Session object so you do not have to add proxies parameter in all your requests:

    import requests
    
    s = requests.Session()
    s.proxies = {"http": "http://61.233.25.166:80"}
    
    r = s.get("http://www.google.com")
    print(r.text)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm familiar with using NSLocalizedString() to localize strings, but the problem I have today
This may be familiar to some. I have a wrapper class Ex that wraps
That sounds familiar I'm sure, but it's not a CSS hack issue. I'm literally
Anyone familiar with specific security issues in the current version of DotNetNuke? (I've already
Anyone familiar with error below? When I run my webapp to generate a dynamic
I am familiar with nunit for unit testing of the business layer however I
If you're familiar with the phrase build one to throw away, well, we seem
Being vaguely familiar with the Java world I was googling for a static analysis
I'm familiar with object-oriented architecture, including use of design patterns and class diagrams for
We're all familiar with the pre- and post-increment operators, e.g. c++; // c =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.