pythonproxyurlliburlopen

Remote end closed connection without response when using a proxy


I am using the code below from this anwser.

import urllib.request
url = 'https://example.com'
proxy_support = urllib.request.ProxyHandler({'http' : '37.26.86.206', 
                                             'https': '37.26.86.206'})
opener = urllib.request.build_opener(proxy_support)
urllib.request.install_opener(opener)

with urllib.request.urlopen(url) as response:
    print(response)

However, I get this error: urllib.error.URLError: <urlopen error Remote end closed connection without response> I don't know why this is, because other people didn't have this problem (that I can find). Is this a problem with my proxy, or is it a problem with the code?
Note: All tracebacks are through urllib, and not my program


Solution

  • I believe the problem was I didn't have a port with the IP. It is fixed now.