MeshProx
← All guides

IPv6 proxy ops

Python + IPv6 Proxies: requests, httpx, Scrapy, and MeshProx Export

Integrate MeshProx SOCKS5/HTTP proxies in Python — socks5h remote DNS, rotating pools, session stickiness, and Scrapy middleware patterns.

2026-06-1910 min read

Part of our IPv6 proxy management guide series.

You generated a CSV from Proxies — now wire it into Python. This guide covers library-specific quirks for IPv6 egress, with patterns that work for MeshProx static, rotating, and sticky proxies.

Export formats from MeshProx

Typical exports look like:

``text socks5://user:pass@203.0.113.10:38421 http://user:pass@203.0.113.10:38422 ``

The host is your VPS IPv4 (SSH/management path). The IPv6 exit is selected by the agent — verify with an IP echo service through the proxy.

For pools, use the pool gateway host:port instead of individual backends (pool guide).

requests + SOCKS5 (recommended for IPv6)

The Requests library does not include SOCKS support by default. Install PySocks:

``bash pip install "requests[socks]" ``

Per Requests proxy documentation and ScrapingBee's proxy guide:

  • socks5:// — DNS resolves locally on your machine
  • socks5h:// — DNS resolves on the proxy (remote DNS)

For scraping, always prefer socks5h so the target sees DNS consistent with the egress IP:

```python import requests

PROXY = "socks5h://USER:PASS@203.0.113.10:38421" proxies = {"http": PROXY, "https": PROXY}

resp = requests.get( "https://api64.ipify.org?format=json", proxies=proxies, timeout=30, ) print(resp.json()) # should show your IPv6 (or IPv4 fallback) exit ```

Use a requests.Session() to reuse connections when hitting the same proxy port with sticky sessions.

Rotating proxy pool in Python

Load MeshProx CSV exports and round-robin:

```python import itertools import random import requests from pathlib import Path

def load_proxies(path: str) -> list[str]: lines = Path(path).read_text().splitlines() return [f"socks5h://{line.split('://', 1)[-1]}" if "://" not in line else line.replace("socks5://", "socks5h://") for line in lines if line.strip()]

class ProxyPool: def __init__(self, urls: list[str], strategy: str = "round_robin"): self.urls = urls self.strategy = strategy self._cycle = itertools.cycle(urls)

def next(self) -> dict[str, str]: url = next(self._cycle) if self.strategy == "round_robin" else random.choice(self.urls) return {"http": url, "https": url}

pool = ProxyPool(load_proxies("meshprox-export.txt"))

for url in targets: r = requests.get(url, proxies=pool.next(), timeout=30) r.raise_for_status() ```

Pacing: Even with rotating IPv6, targets may throttle your whole /64 — see rate limit research.

httpx (async)

``bash pip install httpx[socks] ``

```python import httpx

async with httpx.AsyncClient(proxy="socks5h://USER:PASS@203.0.113.10:38421") as client: r = await client.get("https://example.com") ```

httpx uses the same socks5h convention for remote DNS.

Scrapy + SOCKS5

Scrapy's built-in HttpProxyMiddleware is HTTP-only. SOCKS5 requires a custom downloader middleware or handler — a long-standing gap documented in Scrapy issue #747.

Minimal middleware pattern:

```python # middlewares.py import random

class RotatingSocks5Middleware: def __init__(self, proxies: list[str]): self.proxies = proxies

@classmethod def from_crawler(cls, crawler): return cls(crawler.settings.getlist("MESHPROX_SOCKS5_URLS"))

def process_request(self, request, spider): request.meta["proxy"] = random.choice(self.proxies) # socks5h://... ```

``python # settings.py DOWNLOADER_MIDDLEWARES = { "myproject.middlewares.RotatingSocks5Middleware": 350, } MESHPROX_SOCKS5_URLS = [ "socks5h://user:pass@203.0.113.10:38421", ] ``

For production Scrapy fleets, consider HTTP proxies from MeshProx if you want zero custom handlers — or use scrapy-rotating-proxies with HTTP endpoints.

Playwright / Selenium note

Browser automation tools accept SOCKS5 per-context proxy settings. Use the same socks5h URLs. Sticky proxies matter for checkout flows — match MeshProx sticky mode to cart session length.

MeshProx API automation

Instead of manual CSV export, poll the REST API after rotate events:

  1. Rotate on schedule (rotation guide)
  2. Fetch updated proxy list via API
  3. Hot-reload ProxyPool in your worker

This keeps long-running scrapers aligned with zero-downtime swaps.

Checklist before production

  • [ ] Use socks5h:// not socks5://
  • [ ] Confirm IPv6 exit via echo service (not just proxy connect)
  • [ ] Start with low concurrency; watch block rate
  • [ ] Separate pools per target class (avoid /64 bans)
  • [ ] Re-export after every rotation

Related reading

Pillar guide

Full self-host workflow — pools, rotation, API.

IPv6 proxy management →

Start building

Bring your VPS, run preflight, generate proxies.

Create account