Skip to main content

How to Use Rotating Proxies with Scrapy (2026)

Learn how to use rotating proxies with Scrapy using a single endpoint or custom middleware. Pick the right proxy type and stop getting blocked.

David RazvanDavid Razvan
·3 min read

AI Summary

Get a summary of this page using your preferred AI assistant.

How to Use Rotating Proxies with Scrapy (2026)

Scrapy is fast, but speed means nothing if your requests are getting blocked. Rotating proxies fix that by distributing your crawl traffic across multiple IPs, so no single address trips a rate limit or ban trigger.


Why You Need Proxy Rotation in Scrapy

Scrapy sends requests fast. From a website's perspective, dozens of requests per minute from the same IP looks nothing like a human. Most anti-bot systems trigger on request velocity. Even at moderate speeds, a static IP will eventually get rate-limited or hard-blocked.

The fix is not to slow down. The fix is to spread requests across enough IPs that none of them crosses the detection threshold.


Setting Up Rotating Proxies

The simplest approach is a single rotating endpoint. You point Scrapy at one proxy URL, and the provider handles IP rotation on their end. Add this to settings.py:

Python
1DOWNLOADER_MIDDLEWARES = {
2    'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware': 1,
3}
4
5HTTP_PROXY = 'http://YOUR_USERNAME:YOUR_PASSWORD@residential.proxyon.io:8000'

Every request exits through a different IP automatically.

If you need ban detection and per-request control, use a custom middleware instead. Create middlewares.py:

Python
1import random
2
3class RotatingProxyMiddleware:
4    def __init__(self, proxies):
5        self.proxies = proxies
6
7    @classmethod
8    def from_crawler(cls, crawler):
9        return cls(crawler.settings.getlist('PROXY_LIST'))
10
11    def process_request(self, request, spider):
12        request.meta['proxy'] = random.choice(self.proxies)
13
14    def process_response(self, request, response, spider):
15        if response.status in [403, 429, 503]:
16            blocked = request.meta.get('proxy')
17            if blocked in self.proxies and len(self.proxies) > 1:
18                self.proxies.remove(blocked)
19            new_request = request.copy()
20            new_request.meta['proxy'] = random.choice(self.proxies)
21            return new_request
22        return response

Then register it in settings.py and add your proxy list under PROXY_LIST.

Also Read: What is a Web Scraping Proxy and Why You Need One


Picking the Right Proxy Type

The proxy type matters more than the rotation method.

Datacenter proxies are the right call for targets with light to moderate protection. Fast, cheap, and easy to scale. Proxyon's datacenter proxies run at 1Gbps+ at $0.30/IP.

Residential proxies are what you reach for when the target runs Cloudflare, Akamai, or similar enterprise protection. Requests exit through real ISP-assigned IPs that look identical to organic traffic. Proxyon's residential proxies start at $1.75/GB. Worth it on protected targets. Overkill for open ones.

For scraping flows that require login or multi-step sessions, use sticky sessions. Append a session ID to your proxy username to hold the same IP across requests, then rotate by changing the ID.

Also Read: SOCKS5 vs HTTP Proxy Explained


Final Thought

Proxy rotation is the difference between a Scrapy spider that runs for hours and one that gets blocked in minutes. The single-endpoint setup takes under five minutes. The custom middleware handles ban detection automatically. Start with datacenter proxies for speed and cost, and upgrade to residential when the target demands it. Proxyon offers both on a pay-as-you-go model with no subscription. Deposit $5 and start scraping.

Related Posts

Everything you need to extract web data reliably.

Residential from $1.75/GB, datacenter from $1.50/IP, plus mobile, ISP, and IPv6. Pay-as-you-go. No subscriptions, no contracts. Deposit $5 and start today.

Get Started

Get 100MB free · No credit card required · Instant access