0

I am trying to connect to websites via proxies. I am using the python library requests.

proxies = {
 "http": "http://x.x.x.x:pn",
 "https":  "https://x.x.x.x:pn"
}
request_result = requests.get("https://www.iplocation.net/find-ip-address", proxies=proxies)

These configuration is correct, according to the documentation. I have one proxy from a paid site and I have tried several others that are available on the web. I have also configured this proxies in the windows settings and used them in the browser, it works.

When making the request through Python I get this error:

requests.exceptions.SSLError: HTTPSConnectionPool(host='www.iplocation.net', port=443): Max retries exceeded with url: /find-ip-address (Caused by SSLError(SSLError(1, '[SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:852)'),))

This post says I should check the TLS-version, my environment support TLS 1.2. This post says I should have pyOpenSSL and idna installed, which I do. Why does it say unknown protocol, the request library should be able to connect with Https?

If change the url in the get() function to use the http protocol I sometimes receive:

(Caused by ProxyError('Cannot connect to proxy.', RemoteDisconnected('Remote end closed connection without response',)))

On other occasions I receive a 502 http response.

It is quite frustrating because it should be working. I understand it is a hard question to answer with limited information. Can you give me any suggestions of what might be wrong.

Borut Flis
  • 15,715
  • 30
  • 92
  • 119
  • 1
    It looks like you use the same ip:port with different protocols to access the proxy, i.e. `http://` vs. `https://`. This is likely an error in wrongly assuming that a proxy for HTTPS has to be accessed with `https://`. It might be also a different problem in that the proxy you use does not support proxying HTTPS. – Steffen Ullrich Feb 06 '21 at 16:43
  • By accessing the proxy you mean the configuration in the proxies dictionary? – Borut Flis Feb 06 '21 at 16:51
  • Yeah I used the same port. – Borut Flis Feb 06 '21 at 16:51

0 Answers0