Web scraping
How to avoid IP bans while scraping
An IP ban is the site's blunt answer to traffic it considers too much or too strange from one address. Most bans are avoidable with four habits: pace, rotate sensibly, keep sessions whole, and cache.
What an IP ban really is
An IP ban is a rule on the site's side that refuses or degrades traffic from an address, or from a whole range, after it crosses some threshold. The threshold is rarely published and rarely a single number. It mixes request rate, the share of failed or unusual requests, the reputation of the network the address belongs to, and whatever the site's web application firewall learned from earlier visits. The response can be a hard 403, a 429 with a retry hint, a CAPTCHA on every page, or quietly altered content.
The useful mental model: each address you use has a budget of goodwill with each site. Requests spend it, mistakes spend it faster, and time slowly refills it. Your job is to spend less, spread the spending, and never burn an address in a burst you could have avoided.
Pace requests per host, not per scraper
Rate is the first thing every defense looks at, and it is the cheapest thing to fix. The common mistake is to limit the scraper's total throughput while letting it hammer one host, because the queue happened to be full of URLs from the same domain. Limit per host instead: a fixed number of requests in flight to each domain and a minimum gap between them.
- Start slow. One request every few seconds per host is a sensible first setting for an unknown site. Raise it gradually while watching error rates.
- Add jitter. Perfectly regular intervals are a machine signature. A random delay of plus or minus half the base gap looks more like browsing.
- Honor back-off signals. A
429or503with aRetry-Afterheader is the site telling you its limit. Wait at least that long, and slow down for the rest of the run. - Respect crawl hints. A robots.txt crawl delay, where present, is a good starting pace even when you are not a search engine.
When errors appear, back off exponentially instead of retrying at once. Exponential backoff with jitter stops a small problem from turning into a ban, because the retries thin out exactly when the site is most sensitive.
Rotate addresses for the right reasons
Rotation spreads your requests over many addresses so that none of them crosses a threshold. It works when the requests are independent: separate product pages, search queries, category listings. It backfires when the requests belong together, because a site that sees one visitor change address between page view and form submit has every reason to be suspicious.
So decide per job. Independent fetches can use a rotating proxy that changes address per request or every few minutes. Anything with state, such as a cart, a paginated search with a session token, or a flow that ends in a CAPTCHA, needs the same address from beginning to end. Most proxy setups offer both modes; the sticky session entry explains how the session id usually maps to one exit address.
Size the pool to the job
The pool needs to be large enough that each address stays comfortably below the per-address threshold at your target rate. If you plan a few thousand pages per hour from a site that tolerates a few hundred per address per hour, you need at least a dozen addresses, and more to absorb the ones that get flagged. Rotating ten thousand addresses to fetch a hundred pages, on the other hand, gains nothing and costs money.
Network type matters more than count
Addresses carry the reputation of their network. Datacenter ranges are cheap and fast, and many sites already treat them with suspicion. Residential and mobile addresses look like ordinary visitors and cost more. A small pool on the right network often outlasts a huge pool on the wrong one. The trade-off is laid out in residential or datacenter for CAPTCHAs.
Keep sessions whole
A session is more than an address. It is the address plus cookies, headers, the user agent and the order of pages visited. Sites track these together, so changing one while keeping the others makes a session look stolen or scripted. Keep a session object that bundles all of them and lives for a sensible length, such as a few dozen pages or a few minutes, then retire it and start a fresh one with a new address and clean cookies.
Visit pages in an order a person could plausibly follow. Jumping straight to deep product URLs with no referrer, at a steady rate, for hours, is a pattern even without any single request being unusual. Loading the category page first and following its links costs a little more and spends far less goodwill.
Cache so you ask less often
The request that never happens cannot get you banned. Caching is the most underrated anti-ban measure because it reduces volume without reducing coverage.
- Store raw responses. Keep the HTML or JSON you downloaded, keyed by URL and date. When your parser changes, reparse from disk instead of crawling again.
- Use conditional requests. Send
If-None-MatchorIf-Modified-Sincewhere the site supports them; a304reply is cheap for both sides. - Refresh by value. Pages that rarely change, like product descriptions, can be fetched weekly while prices on the same products are checked daily.
- Prefer feeds and sitemaps. A sitemap with modification dates tells you which pages changed, so you fetch only those.
Watch the signals before the ban
Bans rarely arrive without warning. Response times creep up, CAPTCHAs appear on a few pages, content gets thinner, or redirects start pointing at a check page. Track per host and per address: status code mix, the share of pages that fail your parser, the number of challenge pages, and median latency. When any of them moves, slow down that host before the site does it for you. The monitoring scraper health answer covers which metrics are worth a dashboard.
What to do when a ban happens anyway
First, stop sending traffic from the affected address to that site. Hammering a banned address extends the ban and can spread it to the whole range. Second, find out what kind of block it is. A 403 with a firewall page, a rate-limit reply and a CAPTCHA wall need different fixes, and the guide to Cloudflare 403 responses shows how to read one common family.
If the block is a CAPTCHA rather than a refusal, the site is still willing to talk to you, it just wants proof. That is the moment for a solving API: send the widget's details as a task, put the returned token or cookie into the request, and continue at the slower pace that triggered nothing in the first place. Solving is charged only when an answer comes back, so occasional challenges add a small, predictable cost; frequent challenges, though, mean your pacing or session handling still needs work, and fixing that is cheaper than solving through it.
A balanced default setup
For a typical public data project, a reasonable starting configuration looks like this: two to four concurrent requests per host with a jittered gap, a sticky session of a few minutes per address, a pool of residential addresses sized from your target rate, a response cache on disk, conditional requests for revisits, exponential backoff on errors, and an alert when challenge pages rise above a small share of responses. Tune from there with measurements, not guesses.
Above all, keep the purpose clean. Collecting public prices, rankings or listings at a considerate pace is the kind of job these habits are meant for. Account takeover, credential stuffing and spam are not, and no amount of rotation makes them acceptable.
Common questions
How long does a typical IP ban last?
It varies by site, from minutes for rate limits to weeks for firewall blocks. Many bans expire on their own if the address stops sending traffic for a while.
Is rotating on every request always safer?
No. For anything with state, like pagination tokens or forms, changing address mid-flow looks suspicious. Rotate only between independent requests.
Can a VPN replace a proxy pool for scraping?
A VPN gives you one shared exit address that many others also use, so it often has poor reputation and does not spread load. A pool is a better fit.
Does slowing down really prevent bans?
Pacing removes the most common trigger. It does not fix fingerprint or session problems, but most bans on public pages are rate related.
Should I solve CAPTCHAs or slow down when they appear?
Both. Solve the ones that appear so the job continues, and lower the pace so fewer appear. Rising challenge rates are an early ban warning.
Keep reading
- IP blockingSites block single addresses, whole subnets or entire networks, usually after rate, reputation or abuse signals cross a threshold.
- Rotating proxyA rotating proxy hands out a new exit IP per request or per time window through one gateway address you configure once.
- Rotating or sticky proxies for form flows?Multi-step forms need sticky sessions so the IP stays put; rotation suits independent page fetches with no shared state.
- Scraping without getting blockedA blocking-free scraping checklist: settle these before the first request, watch these during a run, review these afterward.