Using our proxies with HTTPX
HTTPX is a sync and async HTTP client for Python. Since version 0.26 a single proxy is set with proxy=; mounts route different schemes or hosts to different proxies.
Pick a proxyCompatibility
- proxy= on Client, AsyncClient or top-level calls sends all traffic through one proxy; mounts with httpx.HTTPTransport(proxy=...) route per scheme or host.
- The proxies= argument was deprecated in 0.26 and removed in 0.28; older code must be updated to proxy= or mounts.
- Credentials go in the proxy URL: http://username:password@host:port.
- SOCKS support is optional: pip install "httpx[socks]" and use a socks5:// URL.
- HTTP_PROXY, HTTPS_PROXY, ALL_PROXY and NO_PROXY are read by default; trust_env=False turns that off.
- Protocols:
- HTTP, HTTPS (CONNECT), SOCKS5
- Connection:
- Username and password, IP allowlist
Configuration
import httpx
# httpx >= 0.26: proxy= (the old proxies= argument was removed in 0.28)
# SOCKS5 needs: pip install "httpx[socks]" and a socks5:// URL
with httpx.Client(proxy="http://USERNAME:PASSWORD@PROXY_HOST:PORT", timeout=30) as client:
r = client.get("https://api.ipify.org?format=json")
print(r.json())The client sends every request through one HTTP proxy; HTTPS targets are tunnelled. The docs recommend an http:// proxy URL even for https:// traffic, because most proxies accept the first connection over plain HTTP. Remove USERNAME:PASSWORD@ for IP allowlist access.
PROXY_HOST, PORT, USERNAME and PASSWORD are placeholders. After we select proxies for your task, we send you the real host, port and credentials.
Check the result
python -c "import httpx; print(httpx.get('https://api.ipify.org?format=json', proxy='http://USERNAME:PASSWORD@PROXY_HOST:PORT', timeout=30).json())"- Run the one-line test and confirm the printed ip equals the exit IP we sent you.
- Look up the exit IP in two independent GeoIP services and confirm both show the country (and city, if you asked for one) from your request. GeoIP databases can disagree; tell us if they do.
- Fetch one page of your own site or a permitted source through the same client and check status code, redirects and content for that country.
What to put in the request
- HTTPX version (proxy= needs 0.26 or newer) and whether you use sync or async.
- Protocol: HTTP or SOCKS5.
- Access method: username/password or IP allowlist (send the server IP).
- Country, session mode (static, sticky, rotating) and number of concurrent connections.
- The task and the sources involved (your own site, monitoring, permitted public sources).
Common pitfalls
- Copying old examples with proxies=: on HTTPX 0.28+ this raises a TypeError. Use proxy= or mounts.
- A proxy variable left in the environment silently routing traffic; set trust_env=False when the proxy must come only from code.
- Using an https:// proxy URL when the proxy expects plain HTTP on its port; the connection then fails during the TLS handshake.
Recommended proxy types
Sources
Not sure which proxy fits?
Describe the task in two sentences. We reply with a concrete setup and price, usually within one business day.
Availability, exact parameters and price are confirmed in our reply after manual selection. Nothing is charged automatically.