Working SOCKS5 proxy setups for the three Python HTTP clients people actually use, plus the one detail that silently breaks privacy: local vs. remote DNS.
pip install "requests[socks]"import requests proxy = "socks5h://USER:[email protected]:12000" # ^ socks5h = DNS resolved by the proxy, not your machine r = requests.get("https://ipinfo.io/json", proxies={"http": proxy, "https": proxy}, timeout=30) print(r.json())
socks5:// resolves hostnames locally — your DNS resolver sees every domain you scrape. socks5h:// pushes resolution through the exit node. Use socks5h unless you have a reason not to.
pip install "httpx[socks]"import httpx client = httpx.Client(proxy="socks5://USER:[email protected]:12000") print(client.get("https://ipinfo.io/json").json())
pip install aiohttp aiohttp-socks
from aiohttp_socks import ProxyConnector import aiohttp, asyncio async def main(): connector = ProxyConnector.from_url("socks5://USER:[email protected]:12000") async with aiohttp.ClientSession(connector=connector) as s: async with s.get("https://ipinfo.io/json") as r: print(await r.json()) asyncio.run(main())
SOCKS5 is protocol-agnostic — it tunnels raw TCP. That covers non-HTTP traffic (custom protocols, some anti-bot WebSocket checks) and avoids proxy-side header rewriting entirely. Geo flags work the same as HTTP: USER-country-de, -session-x9-lifetime-10, etc.
Full demo across all three clients: socks5.py.
Endpoint used here: QuantumProxies SOCKS5 proxies — residential SOCKS5 on port 12000, 195+ countries, per-GB billing, credentials from app.quantumproxies.io.