How to set up and rotate proxies in Python Scrapy

Updated:

Scrapy's asynchronous Twisted engine includes a built-in HttpProxyMiddleware (at priority 750) that parses http://user:pass@ip:port strings assigned to request.meta['proxy']. Writing a 10-line custom Downloader Middleware at priority 740 lets your spiders rotate across a pool of unmetered VinaProxy static IPs automatically.

Scrapy · HTTP Proxy Format
request.meta['proxy'] = 'http://user:pass@ip:port'
Private IPv4 (datacenter)
🇺🇸 United States
Available
From
₫20,000 / IP / month
≈ $0.74 · billed in VND
Volume pricing
  • 1 IP₫40,000
  • 5+ IPs₫35,000
  • 10+ IPs₫25,000
  • 20+ IPs₫25,000
  • 50+ IPs₫25,000
  • 100+ IPs₫25,000
  • 200+ IPs₫25,000
  • 500+ IPs₫25,000
  • 1000+ IPs₫22,000
  • 2000+ IPs₫20,000
Buy United States
Private IPv4 (datacenter)
🇬🇧 United Kingdom
Available
From
₫20,000 / IP / month
≈ $0.74 · billed in VND
Volume pricing
  • 1 IP₫40,000
  • 5+ IPs₫35,000
  • 10+ IPs₫25,000
  • 20+ IPs₫25,000
  • 50+ IPs₫25,000
  • 100+ IPs₫25,000
  • 200+ IPs₫25,000
  • 500+ IPs₫25,000
  • 1000+ IPs₫22,000
  • 2000+ IPs₫20,000
Buy United Kingdom

Scrapy proxy middleware order & concurrency settings

Because HttpProxyMiddleware runs at order 750 to strip user:pass from the proxy URL and encode the Proxy-Authorization header, any custom middleware setting request.meta['proxy'] must run at a lower number (e.g., 740):

Scrapy SettingRecommended ValuePurpose
request.meta['proxy']'http://user:pass@ip:port'Routes the request through the specified VinaProxy proxy
Middleware Priority740 (before 750)Ensures HttpProxyMiddleware encodes the user:pass header
CONCURRENT_REQUESTS_PER_IP2 to 4Caps simultaneous sockets per proxy IP to avoid HTTP 429
AUTOTHROTTLE_ENABLEDTrueDynamically adapts crawl delay based on target latency

Best practices for high-volume Scrapy crawls

  • Load your VinaProxy proxy list in from_crawler() and assign request.meta['proxy'] = random.choice(self.proxies) inside process_request()
  • Enable RANDOMIZE_DOWNLOAD_DELAY = True alongside DOWNLOAD_DELAY = 1.0 so request intervals per IP never look robotic
  • On retry (429 or 503), pick a different proxy from your pool before re-queueing the request

Step by step

  1. 1

    Format your proxy pool as http://user:pass@ip:port

    Paste your VinaProxy list into our Proxy Format Converter to get URL strings.

  2. 2

    Create a ProxyPoolMiddleware in middlewares.py

    Define process_request(self, request, spider) to set request.meta['proxy'] = random.choice(self.proxies).

  3. 3

    Register at priority 740 in settings.py

    Add 'myproject.middlewares.ProxyPoolMiddleware': 740 under DOWNLOADER_MIDDLEWARES and set CONCURRENT_REQUESTS_PER_IP = 2.

  4. 4

    Test with scrapy shell or scrapy crawl

    Run a test request against https://vinaproxy.com/api/my-ip to verify rotation and authentication.

Frequently asked questions

Why did my custom Scrapy proxy middleware fail when set to priority 800?

Scrapy's built-in HttpProxyMiddleware runs at priority 750. If your middleware runs at 800 (after 750), the inline user:pass credentials are never converted into a Proxy-Authorization header. Always set your middleware priority below 750 (such as 740).

Does Scrapy keep persistent connections open to each proxy?

Yes. Twisted's connection pool maintains persistent keep-alive connections per proxy endpoint.

Are VinaProxy proxies unmetered for multi-million-page Scrapy jobs?

Yes. All Dedicated IPv4 and Static ISP plans include unlimited monthly bandwidth.

Scale your Scrapy spiders with unmetered static IP pools

Instant bulk Dedicated IPv4 and Static ISP proxies across 7 countries.

Buy Scrapy Proxies

Related articles

Proxies by platform
Proxies for Web Scraping: unmetered dedicated IPv4 & ISP pools for 24/7 crawlers
High-speed HTTP(S) dedicated IPv4 and Static ISP proxies for Python, Playwright, Selenium, and Scrapy with unlimited monthly bandwidth.
Proxy setup
How to use a proxy in Python Requests (HTTP/HTTPS & Session pooling)
Configure authenticated HTTP(S) proxies in Python requests and requests.Session(). Handle 407 ProxyError exceptions and rotate static IP pools.
Proxy setup
How to set up a proxy in Playwright (Browser & Per-Context Auth)
Configure authenticated HTTP(S) proxies in Playwright for Node.js and Python. Run multiple isolated static IPs across BrowserContexts.
Free tools
Bulk Proxy Format Converter (100% Client-Side)
100% client-side bulk proxy list formatter. Convert between ip:port:user:pass, user:pass@ip:port, http:// URLs, SOCKS5 URIs, JSON arrays, and FoxyProxy exports.
Proxies by platform
Proxies for SEO & SERP Tracking: accurate keyword rankings across 7 countries
Track localized keyword rankings, audit geo-redirects, and run Screaming Frog crawls with unmetered dedicated IPv4 and Static ISP proxies.
Proxies by platform
Proxies for Amazon: prevent related-account flags across Seller Central, KDP, and Merch
Prevent Amazon related-account suspensions on Seller Central, KDP, and Merch. Dedicated US Static ISP and UK/Japan private IPv4 proxies.
IPV4 · united states
US Private IPv4 Proxies: Fast, Dedicated American Datacenter IPs
Dedicated US private IPv4 proxies for scraping, rank tracking, ad checks and Amazon research. Static IP, one user per IP, unlimited bandwidth, fast activation.
IPV4 · united kingdom
UK Private IPv4 Proxies: Static British Datacenter IPs for Sellers, SEO and Ads
Dedicated UK private IPv4 proxies for eBay UK and Amazon.co.uk research, google.co.uk rank tracking, UK ad checks and social accounts. Unlimited bandwidth.