Requests Configure tor proxy Error: ‘Failed to establish a new connection: [Errno -2] Name or service not known’
socks5 Change to
socks5h
Using the schema socks5 results in DNS resolution happening on the client and not on the proxy. This corresponds to curl, which uses a scheme to decide whether to do DNS resolution on the client or proxy. If you want to allow domains on the proxy, use socks5h as schema.
socks5: DNS resolution without proxy
socks5h: DNS resolution is also proxied
Solution:
import requests
session = requests.session()
session.proxies = {'http': 'socks5h://127.0.0.1:9150', 'https': 'socks5h://127.0.0.1:9150'}
response = session.get("https://3g2upl4pq6kufc4m.onion/")
print(response)
#<Response [200]>
Similar Posts:
- [Solved] Git submission: gnutls_handshake() failed: Error in the pull function
- [Solved] CURL Install Error: GnuTLS: The TLS connection was non-properly terminated. Unable to establish SSL connection.
- Nginx Timeout Error: upstream timed out (110: Connection timed out) while reading response header from ups…
- The solution of ‘STR’ object has no attribute ‘get’ error
- Differences of urllib, urllib2, httplib and httplib2 libraries in Python
- Installing Ubuntu 16.04 on XPS 13
- Python3 Use urlliburlopen error EOF occurred in violation of protocol (_ssl.c:841)
- [Mac] How to Solve Android Studio error: Unable to access Android SDK add-on list
- This content should also be served over HTTPS
- MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors