Python HTTPX proxy setup

Python HTTPX is one of the most common HTTP clients in scraping stacks. Point it at a PinguProxy endpoint and every request it makes exits through your proxy IP — static or rotating, over HTTP or SOCKS5.

Why use proxies with Python HTTPX

Direct requests expose your home IP and get rate-limited fast. With Python HTTPX behind PinguProxy, retries and bursts come from proxy IPs instead, so targets see distributed traffic instead of one noisy client.

What you can do

  • Keep one static IP per job so a target can whitelist or cookie you consistently.
  • Rotate per request with SOCKS5h so scraping bursts look like real distributed traffic.
  • Pool sessions with retries for long-running jobs that survive 429s and timeouts.
  • Use IPv4 or IPv6 exits depending on what the target infrastructure supports.

Setup snippets

Replace username, password, and port with the credentials from your dashboard. All examples route both HTTP and HTTPS traffic through the proxy.

Static IP (HTTP proxy)
import httpx
proxy = "http://username:password@proxy.pinguproxy.com:12933"
with httpx.Client(proxy=proxy, timeout=10) as client:
response = client.get("https://pinguproxy.com/ip")
print(response.text) # your proxy's exit IP
Rotating IP (SOCKS5h)
# pip install "httpx[socks]"
import httpx
# SOCKS5h resolves DNS on the proxy, so the exit IP is never leaked.
proxy = "socks5h://username:password@proxy.pinguproxy.com:12933"
with httpx.Client(proxy=proxy, timeout=10) as client:
for _ in range(5):
print(client.get("https://pinguproxy.com/ip").text)
Async client
import asyncio
import httpx
proxy = "http://username:password@proxy.pinguproxy.com:12933"
async def fetch(client, url):
response = await client.get(url)
return response.status_code
async def main():
async with httpx.AsyncClient(proxy=proxy, timeout=10) as client:
statuses = await asyncio.gather(
*[fetch(client, url) for url in ["https://example.com", "https://example.org"]],
)
print(statuses)
asyncio.run(main())

The port shown (12933) is the default example; your dashboard lists the exact endpoints for your proxies. SOCKS5h keeps DNS lookups on the proxy so your real DNS server never sees the target domains.

Frequently asked questions

Does Python HTTPX support SOCKS5?

Yes — modern Python HTTPX bundles the socks support needed for socks5h:// URLs; just install requests[socks] if your environment asks for it.

How do I rotate IPs per request with Python HTTPX?

Point Python HTTPX at the rotating SOCKS5h endpoint: each new connection picks a fresh exit IP, while sticky sessions keep one IP until you ask for a new one.

Can I keep the same IP for a whole scraping session?

Yes. Use the static HTTP endpoint and the same proxy URL for every request — the exit IP stays fixed until you switch proxies in the dashboard.

Other setup guides

Ready to connect Python HTTPX?

Create a proxy in the dashboard and paste your credentials into the snippets above — unlimited bandwidth on every plan.